﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibKetoan;

namespace Ketoan
{
	/// <summary>
	/// Summary description for frmReport_yc.
	/// </summary>
	public class frmReport_sc : System.Windows.Forms.Form
	{
		#region khai bao cac bien su dung trong form
		private DataRow r;
		private AccessData a;	
		private int i_Iduser=0;
		private System.Data.DataSet ds_Data;
		private string s_Tenform="";
		private string s_Report="";
		private string s_fTieude_chinh="",s_Pagesize="A4";
		private exportExcel exportExcel=new exportExcel();
		private string s_sotk="";
		private DataTable dt_Dmchuong,dt_Dmtk,dt_Dmlk,dt_Dmmuc,dt_Dmhoatdong,dt_Khoaphong,dt_Dmloaidt;
		private DataTable dt_Dmdoituong,dt_Dmnhombc,dt_Dmkhoanmuc1,dt_Dmkhoanmuc2,dt_Dmkhoanmuc3,dt_Dmkhoanmuc4;
		//private int i_HChuong=0,i_HTaikhoan=0,i_HLoaikhoan=0,i_HMuc=0,i_HHoatdong=0,i_HKhoaphong=0,i_HDoituong=0;
		//private int i_HKhoanmuc=0,i_HNhombc=0,
		private int i_Kieuin=1, i_Banin=1;
		private bool b_Lctu=true,b_Khoanmuc=true,b_Khoanmuc2=true,b_Khoanmuc3=true,b_Khoanmuc4=true,b_Muc=true;	
		private string ngayin="",ngaythangnam="",stk = "",doituong="",khoanmuc="",text3="",ttk="";
		#endregion dong khai bao bien su dung trong form

		#region khai bao control

		private System.Windows.Forms.GroupBox grpNen;
		private System.Windows.Forms.Label lbltaikhoan;
		private System.Windows.Forms.Label lbldoituong;
		private System.Windows.Forms.Label lblnhombc;
		private System.Windows.Forms.Label lblchuong;
		private System.Windows.Forms.Label lblhoatdong;
		private System.Windows.Forms.Label lblloaikhoan;
		private System.Windows.Forms.Label lblmuc;
		private System.Windows.Forms.Label lblkhoanmuc1;
		private System.Windows.Forms.Label lblkhoanmuc2;
		private System.Windows.Forms.Label lblkhoanmuc3;
		private System.Windows.Forms.Label lblkhoanmuc4;
		private System.Windows.Forms.Label lblbctheo;
		private System.Windows.Forms.Button butExcel;
		private System.Windows.Forms.Button butKetthuc;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butXem;
		private System.Windows.Forms.TextBox txtsotaikhoan;
		private System.Windows.Forms.TextBox txttentaikhoan;
		private LibList.List listdoituong;
		private System.Windows.Forms.TextBox txttendoituong;
		private System.Windows.Forms.TextBox txtdoituong;
		private System.Windows.Forms.TextBox txttenchuong;
		private System.Windows.Forms.TextBox txtchuong;
		private System.Windows.Forms.TextBox txttenhoatdong;
		private System.Windows.Forms.TextBox txthoatdong;
		private System.Windows.Forms.TextBox txttenloaikhoan;
		private System.Windows.Forms.TextBox txtloaikhoan;
		private System.Windows.Forms.TextBox txttenmuc;
		private System.Windows.Forms.TextBox txtmuc;
		private System.Windows.Forms.TextBox txttenkhoanmuc1;
		private System.Windows.Forms.TextBox txtkhoanmuc1;
		private System.Windows.Forms.TextBox txttenkhoanmuc2;
		private System.Windows.Forms.TextBox txtkhoanmuc2;
		private System.Windows.Forms.TextBox txttenkhoanmuc3;
		private System.Windows.Forms.TextBox txtkhoanmuc3;
		private System.Windows.Forms.TextBox txttenkhoanmuc4;
		private System.Windows.Forms.TextBox txtkhoanmuc4;
		private LibList.List listchuong;
		private LibList.List listkhoanmuc1;
		private LibList.List listtaikhoan;
		private LibList.List listloaikhoan;
		private LibList.List listhoatdong;
		private LibList.List listmuc;
		private LibList.List listkhoanmuc2;
		private LibList.List listkhoanmuc3;
		private LibList.List listkhoanmuc4;
		private LibList.List listnhombc;
		private System.Windows.Forms.TextBox txttennhombc;
		private System.Windows.Forms.ComboBox cbochon;
		private System.Windows.Forms.ComboBox cbobctheo;
		private System.Windows.Forms.NumericUpDown numNam;
		private System.Windows.Forms.RadioButton rdbTheothang;
		private System.Windows.Forms.RadioButton rdbTheongay;
		private System.Windows.Forms.TextBox txtnhombc;
		private System.Windows.Forms.DateTimePicker dtpTungay;
		private System.Windows.Forms.DateTimePicker dtpDenngay;
		private System.Windows.Forms.NumericUpDown numDenthang;
		private System.Windows.Forms.NumericUpDown numTuthang;
		private System.Windows.Forms.GroupBox grbchon;
		private System.Windows.Forms.GroupBox grbNgay;
		private System.Windows.Forms.GroupBox grbThang;
		private System.Windows.Forms.Label lblTungay;
		private System.Windows.Forms.Label lblDenngay;
		private System.Windows.Forms.Label lblTuthang;
		private System.Windows.Forms.Label lblDenthang;
		private System.Windows.Forms.Label lblError;
		private System.Windows.Forms.Label lblNam;
		private System.Windows.Forms.TextBox txttenloaidt;
		private System.Windows.Forms.TextBox txtloaidt;
		private System.Windows.Forms.Label lblloaidt;
		private LibList.List listloaidt;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		#endregion dong khai bao control

		public frmReport_sc(LibKetoan.AccessData acc, string s_Form, int i_iduser)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			a=acc;
			s_Tenform=s_Form;
			i_Iduser=i_iduser;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmReport_sc));
            this.grpNen = new System.Windows.Forms.GroupBox();
            this.txttenloaidt = new System.Windows.Forms.TextBox();
            this.txtloaidt = new System.Windows.Forms.TextBox();
            this.lblloaidt = new System.Windows.Forms.Label();
            this.txtnhombc = new System.Windows.Forms.TextBox();
            this.cbobctheo = new System.Windows.Forms.ComboBox();
            this.txttennhombc = new System.Windows.Forms.TextBox();
            this.cbochon = new System.Windows.Forms.ComboBox();
            this.txttenloaikhoan = new System.Windows.Forms.TextBox();
            this.txtloaikhoan = new System.Windows.Forms.TextBox();
            this.txttenhoatdong = new System.Windows.Forms.TextBox();
            this.txthoatdong = new System.Windows.Forms.TextBox();
            this.txtmuc = new System.Windows.Forms.TextBox();
            this.txttenchuong = new System.Windows.Forms.TextBox();
            this.txtchuong = new System.Windows.Forms.TextBox();
            this.txttendoituong = new System.Windows.Forms.TextBox();
            this.lblbctheo = new System.Windows.Forms.Label();
            this.txtkhoanmuc1 = new System.Windows.Forms.TextBox();
            this.txtdoituong = new System.Windows.Forms.TextBox();
            this.txttentaikhoan = new System.Windows.Forms.TextBox();
            this.txtsotaikhoan = new System.Windows.Forms.TextBox();
            this.lblloaikhoan = new System.Windows.Forms.Label();
            this.listmuc = new LibList.List();
            this.lblhoatdong = new System.Windows.Forms.Label();
            this.lblchuong = new System.Windows.Forms.Label();
            this.lblnhombc = new System.Windows.Forms.Label();
            this.lblmuc = new System.Windows.Forms.Label();
            this.lbldoituong = new System.Windows.Forms.Label();
            this.listkhoanmuc1 = new LibList.List();
            this.lbltaikhoan = new System.Windows.Forms.Label();
            this.lblkhoanmuc1 = new System.Windows.Forms.Label();
            this.txttenkhoanmuc1 = new System.Windows.Forms.TextBox();
            this.txttenmuc = new System.Windows.Forms.TextBox();
            this.txttenkhoanmuc4 = new System.Windows.Forms.TextBox();
            this.txtkhoanmuc4 = new System.Windows.Forms.TextBox();
            this.txttenkhoanmuc3 = new System.Windows.Forms.TextBox();
            this.txtkhoanmuc3 = new System.Windows.Forms.TextBox();
            this.txttenkhoanmuc2 = new System.Windows.Forms.TextBox();
            this.txtkhoanmuc2 = new System.Windows.Forms.TextBox();
            this.lblkhoanmuc4 = new System.Windows.Forms.Label();
            this.lblkhoanmuc3 = new System.Windows.Forms.Label();
            this.lblkhoanmuc2 = new System.Windows.Forms.Label();
            this.listdoituong = new LibList.List();
            this.butExcel = new System.Windows.Forms.Button();
            this.butKetthuc = new System.Windows.Forms.Button();
            this.butIn = new System.Windows.Forms.Button();
            this.butXem = new System.Windows.Forms.Button();
            this.listchuong = new LibList.List();
            this.listtaikhoan = new LibList.List();
            this.listloaikhoan = new LibList.List();
            this.listhoatdong = new LibList.List();
            this.listkhoanmuc2 = new LibList.List();
            this.listkhoanmuc3 = new LibList.List();
            this.listkhoanmuc4 = new LibList.List();
            this.listnhombc = new LibList.List();
            this.grbNgay = new System.Windows.Forms.GroupBox();
            this.dtpDenngay = new System.Windows.Forms.DateTimePicker();
            this.lblDenngay = new System.Windows.Forms.Label();
            this.dtpTungay = new System.Windows.Forms.DateTimePicker();
            this.lblTungay = new System.Windows.Forms.Label();
            this.grbThang = new System.Windows.Forms.GroupBox();
            this.numDenthang = new System.Windows.Forms.NumericUpDown();
            this.numTuthang = new System.Windows.Forms.NumericUpDown();
            this.numNam = new System.Windows.Forms.NumericUpDown();
            this.lblNam = new System.Windows.Forms.Label();
            this.lblDenthang = new System.Windows.Forms.Label();
            this.lblTuthang = new System.Windows.Forms.Label();
            this.grbchon = new System.Windows.Forms.GroupBox();
            this.rdbTheothang = new System.Windows.Forms.RadioButton();
            this.rdbTheongay = new System.Windows.Forms.RadioButton();
            this.lblError = new System.Windows.Forms.Label();
            this.listloaidt = new LibList.List();
            this.grpNen.SuspendLayout();
            this.grbNgay.SuspendLayout();
            this.grbThang.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numDenthang)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numTuthang)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numNam)).BeginInit();
            this.grbchon.SuspendLayout();
            this.SuspendLayout();
            // 
            // grpNen
            // 
            this.grpNen.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grpNen.BackColor = System.Drawing.SystemColors.Control;
            this.grpNen.Controls.Add(this.txttenloaidt);
            this.grpNen.Controls.Add(this.txtloaidt);
            this.grpNen.Controls.Add(this.lblloaidt);
            this.grpNen.Controls.Add(this.txtnhombc);
            this.grpNen.Controls.Add(this.cbobctheo);
            this.grpNen.Controls.Add(this.txttennhombc);
            this.grpNen.Controls.Add(this.cbochon);
            this.grpNen.Controls.Add(this.txttenloaikhoan);
            this.grpNen.Controls.Add(this.txtloaikhoan);
            this.grpNen.Controls.Add(this.txttenhoatdong);
            this.grpNen.Controls.Add(this.txthoatdong);
            this.grpNen.Controls.Add(this.txtmuc);
            this.grpNen.Controls.Add(this.txttenchuong);
            this.grpNen.Controls.Add(this.txtchuong);
            this.grpNen.Controls.Add(this.txttendoituong);
            this.grpNen.Controls.Add(this.lblbctheo);
            this.grpNen.Controls.Add(this.txtkhoanmuc1);
            this.grpNen.Controls.Add(this.txtdoituong);
            this.grpNen.Controls.Add(this.txttentaikhoan);
            this.grpNen.Controls.Add(this.txtsotaikhoan);
            this.grpNen.Controls.Add(this.lblloaikhoan);
            this.grpNen.Controls.Add(this.listmuc);
            this.grpNen.Controls.Add(this.lblhoatdong);
            this.grpNen.Controls.Add(this.lblchuong);
            this.grpNen.Controls.Add(this.lblnhombc);
            this.grpNen.Controls.Add(this.lblmuc);
            this.grpNen.Controls.Add(this.lbldoituong);
            this.grpNen.Controls.Add(this.listkhoanmuc1);
            this.grpNen.Controls.Add(this.lbltaikhoan);
            this.grpNen.Controls.Add(this.lblkhoanmuc1);
            this.grpNen.Controls.Add(this.txttenkhoanmuc1);
            this.grpNen.Controls.Add(this.txttenmuc);
            this.grpNen.Location = new System.Drawing.Point(8, 56);
            this.grpNen.Name = "grpNen";
            this.grpNen.Size = new System.Drawing.Size(464, 235);
            this.grpNen.TabIndex = 3;
            this.grpNen.TabStop = false;
            // 
            // txttenloaidt
            // 
            this.txttenloaidt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenloaidt.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenloaidt.Location = new System.Drawing.Point(152, 40);
            this.txttenloaidt.Name = "txttenloaidt";
            this.txttenloaidt.Size = new System.Drawing.Size(296, 20);
            this.txttenloaidt.TabIndex = 26;
            // 
            // txtloaidt
            // 
            this.txtloaidt.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtloaidt.Location = new System.Drawing.Point(88, 40);
            this.txtloaidt.Name = "txtloaidt";
            this.txtloaidt.Size = new System.Drawing.Size(63, 20);
            this.txtloaidt.TabIndex = 25;
            this.txtloaidt.DoubleClick += new System.EventHandler(this.txtloaidt_DoubleClick);
            this.txtloaidt.TextChanged += new System.EventHandler(this.txtloaidt_TextChanged);
            this.txtloaidt.Validated += new System.EventHandler(this.txtloaidt_Validated);
            this.txtloaidt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtloaidt_KeyDown);
            // 
            // lblloaidt
            // 
            this.lblloaidt.Location = new System.Drawing.Point(8, 40);
            this.lblloaidt.Name = "lblloaidt";
            this.lblloaidt.Size = new System.Drawing.Size(80, 23);
            this.lblloaidt.TabIndex = 24;
            this.lblloaidt.Text = "Loại đối tượng:";
            this.lblloaidt.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtnhombc
            // 
            this.txtnhombc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtnhombc.Location = new System.Drawing.Point(88, 88);
            this.txtnhombc.Name = "txtnhombc";
            this.txtnhombc.Size = new System.Drawing.Size(63, 20);
            this.txtnhombc.TabIndex = 4;
            this.txtnhombc.DoubleClick += new System.EventHandler(this.txtnhombc_DoubleClick);
            this.txtnhombc.TextChanged += new System.EventHandler(this.txtnhombc_TextChanged);
            this.txtnhombc.Validated += new System.EventHandler(this.txtnhombc_Validated);
            this.txtnhombc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtnhombc_KeyDown);
            // 
            // cbobctheo
            // 
            this.cbobctheo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.cbobctheo.ForeColor = System.Drawing.Color.DarkBlue;
            this.cbobctheo.Items.AddRange(new object[] {
            "Chương",
            "Đối tượng",
            "Hoạt động",
            "Mục",
            "Nhóm báo cáo",
            "Khoản mục"});
            this.cbobctheo.Location = new System.Drawing.Point(288, 207);
            this.cbobctheo.Name = "cbobctheo";
            this.cbobctheo.Size = new System.Drawing.Size(160, 21);
            this.cbobctheo.TabIndex = 23;
            // 
            // txttennhombc
            // 
            this.txttennhombc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttennhombc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttennhombc.Location = new System.Drawing.Point(152, 88);
            this.txttennhombc.Name = "txttennhombc";
            this.txttennhombc.Size = new System.Drawing.Size(296, 20);
            this.txttennhombc.TabIndex = 5;
            // 
            // cbochon
            // 
            this.cbochon.ForeColor = System.Drawing.Color.DarkBlue;
            this.cbochon.Items.AddRange(new object[] {
            "Chương",
            "Đối tượng",
            "Hoạt động",
            "Mục",
            "Nhóm báo cáo",
            "Khoản mục",
            "Khoản mục có",
            "Khoản mục 2",
            "Khoản mục có 2",
            "Khoản mục 3",
            "Khoản mục có 3",
            "Khoản mục 4",
            "Khoản mục có 4"});
            this.cbochon.Location = new System.Drawing.Point(88, 207);
            this.cbochon.Name = "cbochon";
            this.cbochon.Size = new System.Drawing.Size(200, 21);
            this.cbochon.TabIndex = 22;
            // 
            // txttenloaikhoan
            // 
            this.txttenloaikhoan.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenloaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenloaikhoan.Location = new System.Drawing.Point(152, 160);
            this.txttenloaikhoan.Name = "txttenloaikhoan";
            this.txttenloaikhoan.Size = new System.Drawing.Size(296, 20);
            this.txttenloaikhoan.TabIndex = 11;
            // 
            // txtloaikhoan
            // 
            this.txtloaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtloaikhoan.Location = new System.Drawing.Point(88, 160);
            this.txtloaikhoan.Name = "txtloaikhoan";
            this.txtloaikhoan.Size = new System.Drawing.Size(63, 20);
            this.txtloaikhoan.TabIndex = 10;
            this.txtloaikhoan.DoubleClick += new System.EventHandler(this.txtloaikhoan_DoubleClick);
            this.txtloaikhoan.TextChanged += new System.EventHandler(this.txtloaikhoan_TextChanged);
            this.txtloaikhoan.Validated += new System.EventHandler(this.txtloaikhoan_Validated);
            this.txtloaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtloaikhoan_KeyDown);
            // 
            // txttenhoatdong
            // 
            this.txttenhoatdong.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenhoatdong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenhoatdong.Location = new System.Drawing.Point(152, 136);
            this.txttenhoatdong.Name = "txttenhoatdong";
            this.txttenhoatdong.Size = new System.Drawing.Size(296, 20);
            this.txttenhoatdong.TabIndex = 9;
            // 
            // txthoatdong
            // 
            this.txthoatdong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txthoatdong.Location = new System.Drawing.Point(88, 136);
            this.txthoatdong.Name = "txthoatdong";
            this.txthoatdong.Size = new System.Drawing.Size(63, 20);
            this.txthoatdong.TabIndex = 8;
            this.txthoatdong.DoubleClick += new System.EventHandler(this.txthoatdong_DoubleClick);
            this.txthoatdong.TextChanged += new System.EventHandler(this.txthoatdong_TextChanged);
            this.txthoatdong.Validated += new System.EventHandler(this.txthoatdong_Validated);
            this.txthoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txthoatdong_KeyDown);
            // 
            // txtmuc
            // 
            this.txtmuc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtmuc.Location = new System.Drawing.Point(88, 183);
            this.txtmuc.Name = "txtmuc";
            this.txtmuc.Size = new System.Drawing.Size(63, 20);
            this.txtmuc.TabIndex = 12;
            this.txtmuc.DoubleClick += new System.EventHandler(this.txtmuc_DoubleClick);
            this.txtmuc.TextChanged += new System.EventHandler(this.txtmuc_TextChanged);
            this.txtmuc.Validated += new System.EventHandler(this.txtmuc_Validated);
            this.txtmuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtmuc_KeyDown);
            this.txtmuc.Enter += new System.EventHandler(this.txtmuc_Enter);
            // 
            // txttenchuong
            // 
            this.txttenchuong.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenchuong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenchuong.Location = new System.Drawing.Point(152, 112);
            this.txttenchuong.Name = "txttenchuong";
            this.txttenchuong.Size = new System.Drawing.Size(296, 20);
            this.txttenchuong.TabIndex = 7;
            // 
            // txtchuong
            // 
            this.txtchuong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtchuong.Location = new System.Drawing.Point(88, 112);
            this.txtchuong.Name = "txtchuong";
            this.txtchuong.Size = new System.Drawing.Size(63, 20);
            this.txtchuong.TabIndex = 6;
            this.txtchuong.DoubleClick += new System.EventHandler(this.txtchuong_DoubleClick);
            this.txtchuong.TextChanged += new System.EventHandler(this.txtchuong_TextChanged);
            this.txtchuong.Validated += new System.EventHandler(this.txtchuong_Validated);
            this.txtchuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtchuong_KeyDown);
            // 
            // txttendoituong
            // 
            this.txttendoituong.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttendoituong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttendoituong.Location = new System.Drawing.Point(152, 64);
            this.txttendoituong.Name = "txttendoituong";
            this.txttendoituong.Size = new System.Drawing.Size(296, 20);
            this.txttendoituong.TabIndex = 3;
            // 
            // lblbctheo
            // 
            this.lblbctheo.Location = new System.Drawing.Point(8, 205);
            this.lblbctheo.Name = "lblbctheo";
            this.lblbctheo.Size = new System.Drawing.Size(80, 23);
            this.lblbctheo.TabIndex = 11;
            this.lblbctheo.Text = "Báo cáo theo:";
            this.lblbctheo.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtkhoanmuc1
            // 
            this.txtkhoanmuc1.Enabled = false;
            this.txtkhoanmuc1.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtkhoanmuc1.Location = new System.Drawing.Point(88, 205);
            this.txtkhoanmuc1.Name = "txtkhoanmuc1";
            this.txtkhoanmuc1.Size = new System.Drawing.Size(0, 20);
            this.txtkhoanmuc1.TabIndex = 14;
            this.txtkhoanmuc1.Visible = false;
            this.txtkhoanmuc1.DoubleClick += new System.EventHandler(this.txtkhoanmuc1_DoubleClick);
            this.txtkhoanmuc1.TextChanged += new System.EventHandler(this.txtkhoanmuc1_TextChanged);
            this.txtkhoanmuc1.Validated += new System.EventHandler(this.txtkhoanmuc1_Validated);
            this.txtkhoanmuc1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtkhoanmuc1_KeyDown);
            this.txtkhoanmuc1.Enter += new System.EventHandler(this.txtkhoanmuc1_Enter);
            // 
            // txtdoituong
            // 
            this.txtdoituong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtdoituong.Location = new System.Drawing.Point(88, 64);
            this.txtdoituong.Name = "txtdoituong";
            this.txtdoituong.Size = new System.Drawing.Size(63, 20);
            this.txtdoituong.TabIndex = 2;
            this.txtdoituong.DoubleClick += new System.EventHandler(this.txtdoituong_DoubleClick);
            this.txtdoituong.TextChanged += new System.EventHandler(this.txtdoituong_TextChanged);
            this.txtdoituong.Validated += new System.EventHandler(this.txtdoituong_Validated);
            this.txtdoituong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtdoituong_KeyDown);
            this.txtdoituong.Enter += new System.EventHandler(this.txtdoituong_Enter);
            // 
            // txttentaikhoan
            // 
            this.txttentaikhoan.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttentaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttentaikhoan.Location = new System.Drawing.Point(152, 16);
            this.txttentaikhoan.Name = "txttentaikhoan";
            this.txttentaikhoan.Size = new System.Drawing.Size(296, 20);
            this.txttentaikhoan.TabIndex = 1;
            // 
            // txtsotaikhoan
            // 
            this.txtsotaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtsotaikhoan.Location = new System.Drawing.Point(88, 16);
            this.txtsotaikhoan.Name = "txtsotaikhoan";
            this.txtsotaikhoan.Size = new System.Drawing.Size(63, 20);
            this.txtsotaikhoan.TabIndex = 0;
            this.txtsotaikhoan.DoubleClick += new System.EventHandler(this.txtsotaikhoan_DoubleClick);
            this.txtsotaikhoan.TextChanged += new System.EventHandler(this.txtsotaikhoan_TextChanged);
            this.txtsotaikhoan.Validated += new System.EventHandler(this.txtsotaikhoan_Validated);
            this.txtsotaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtsotaikhoan_KeyDown);
            // 
            // lblloaikhoan
            // 
            this.lblloaikhoan.Location = new System.Drawing.Point(16, 158);
            this.lblloaikhoan.Name = "lblloaikhoan";
            this.lblloaikhoan.Size = new System.Drawing.Size(72, 23);
            this.lblloaikhoan.TabIndex = 5;
            this.lblloaikhoan.Text = "Loại khoản:";
            this.lblloaikhoan.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // listmuc
            // 
            this.listmuc.BackColor = System.Drawing.SystemColors.Info;
            this.listmuc.ColumnCount = 0;
            this.listmuc.Location = new System.Drawing.Point(159, 184);
            this.listmuc.MatchBufferTimeOut = 1000;
            this.listmuc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listmuc.Name = "listmuc";
            this.listmuc.Size = new System.Drawing.Size(75, 17);
            this.listmuc.TabIndex = 7;
            this.listmuc.TextIndex = -1;
            this.listmuc.TextMember = null;
            this.listmuc.ValueIndex = -1;
            this.listmuc.Visible = false;
            // 
            // lblhoatdong
            // 
            this.lblhoatdong.Location = new System.Drawing.Point(16, 136);
            this.lblhoatdong.Name = "lblhoatdong";
            this.lblhoatdong.Size = new System.Drawing.Size(72, 23);
            this.lblhoatdong.TabIndex = 4;
            this.lblhoatdong.Text = "Hoạt động:";
            this.lblhoatdong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblchuong
            // 
            this.lblchuong.Location = new System.Drawing.Point(16, 109);
            this.lblchuong.Name = "lblchuong";
            this.lblchuong.Size = new System.Drawing.Size(72, 23);
            this.lblchuong.TabIndex = 3;
            this.lblchuong.Text = "Chương:";
            this.lblchuong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblnhombc
            // 
            this.lblnhombc.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblnhombc.Location = new System.Drawing.Point(8, 88);
            this.lblnhombc.Name = "lblnhombc";
            this.lblnhombc.Size = new System.Drawing.Size(80, 23);
            this.lblnhombc.TabIndex = 2;
            this.lblnhombc.Text = "Nhóm b/c:";
            this.lblnhombc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblmuc
            // 
            this.lblmuc.Location = new System.Drawing.Point(8, 180);
            this.lblmuc.Name = "lblmuc";
            this.lblmuc.Size = new System.Drawing.Size(80, 23);
            this.lblmuc.TabIndex = 6;
            this.lblmuc.Text = "Mục:";
            this.lblmuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lbldoituong
            // 
            this.lbldoituong.Location = new System.Drawing.Point(8, 64);
            this.lbldoituong.Name = "lbldoituong";
            this.lbldoituong.Size = new System.Drawing.Size(80, 23);
            this.lbldoituong.TabIndex = 1;
            this.lbldoituong.Text = "Đối tượng:";
            this.lbldoituong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // listkhoanmuc1
            // 
            this.listkhoanmuc1.BackColor = System.Drawing.SystemColors.Info;
            this.listkhoanmuc1.ColumnCount = 0;
            this.listkhoanmuc1.Location = new System.Drawing.Point(159, 205);
            this.listkhoanmuc1.MatchBufferTimeOut = 1000;
            this.listkhoanmuc1.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listkhoanmuc1.Name = "listkhoanmuc1";
            this.listkhoanmuc1.Size = new System.Drawing.Size(0, 4);
            this.listkhoanmuc1.TabIndex = 8;
            this.listkhoanmuc1.TextIndex = -1;
            this.listkhoanmuc1.TextMember = null;
            this.listkhoanmuc1.ValueIndex = -1;
            this.listkhoanmuc1.Visible = false;
            // 
            // lbltaikhoan
            // 
            this.lbltaikhoan.Location = new System.Drawing.Point(8, 16);
            this.lbltaikhoan.Name = "lbltaikhoan";
            this.lbltaikhoan.Size = new System.Drawing.Size(80, 23);
            this.lbltaikhoan.TabIndex = 0;
            this.lbltaikhoan.Text = "Tài khoản:";
            this.lbltaikhoan.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblkhoanmuc1
            // 
            this.lblkhoanmuc1.Enabled = false;
            this.lblkhoanmuc1.Location = new System.Drawing.Point(6, 203);
            this.lblkhoanmuc1.Name = "lblkhoanmuc1";
            this.lblkhoanmuc1.Size = new System.Drawing.Size(0, 0);
            this.lblkhoanmuc1.TabIndex = 7;
            this.lblkhoanmuc1.Text = "Nguồn:";
            this.lblkhoanmuc1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.lblkhoanmuc1.Visible = false;
            // 
            // txttenkhoanmuc1
            // 
            this.txttenkhoanmuc1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenkhoanmuc1.Enabled = false;
            this.txttenkhoanmuc1.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenkhoanmuc1.Location = new System.Drawing.Point(152, 205);
            this.txttenkhoanmuc1.Name = "txttenkhoanmuc1";
            this.txttenkhoanmuc1.Size = new System.Drawing.Size(0, 20);
            this.txttenkhoanmuc1.TabIndex = 15;
            this.txttenkhoanmuc1.Visible = false;
            // 
            // txttenmuc
            // 
            this.txttenmuc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenmuc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenmuc.Location = new System.Drawing.Point(152, 183);
            this.txttenmuc.Name = "txttenmuc";
            this.txttenmuc.Size = new System.Drawing.Size(296, 20);
            this.txttenmuc.TabIndex = 13;
            this.txttenmuc.TextChanged += new System.EventHandler(this.txttenmuc_TextChanged);
            // 
            // txttenkhoanmuc4
            // 
            this.txttenkhoanmuc4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenkhoanmuc4.Enabled = false;
            this.txttenkhoanmuc4.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenkhoanmuc4.Location = new System.Drawing.Point(168, 537);
            this.txttenkhoanmuc4.Name = "txttenkhoanmuc4";
            this.txttenkhoanmuc4.Size = new System.Drawing.Size(296, 20);
            this.txttenkhoanmuc4.TabIndex = 21;
            this.txttenkhoanmuc4.Visible = false;
            // 
            // txtkhoanmuc4
            // 
            this.txtkhoanmuc4.Enabled = false;
            this.txtkhoanmuc4.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtkhoanmuc4.Location = new System.Drawing.Point(104, 537);
            this.txtkhoanmuc4.Name = "txtkhoanmuc4";
            this.txtkhoanmuc4.Size = new System.Drawing.Size(63, 20);
            this.txtkhoanmuc4.TabIndex = 20;
            this.txtkhoanmuc4.Visible = false;
            this.txtkhoanmuc4.DoubleClick += new System.EventHandler(this.txtkhoanmuc4_DoubleClick);
            this.txtkhoanmuc4.TextChanged += new System.EventHandler(this.txtkhoanmuc4_TextChanged);
            this.txtkhoanmuc4.Validated += new System.EventHandler(this.txtkhoanmuc4_Validated);
            this.txtkhoanmuc4.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtkhoanmuc4_KeyDown);
            this.txtkhoanmuc4.Enter += new System.EventHandler(this.txtkhoanmuc4_Enter);
            // 
            // txttenkhoanmuc3
            // 
            this.txttenkhoanmuc3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenkhoanmuc3.Enabled = false;
            this.txttenkhoanmuc3.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenkhoanmuc3.Location = new System.Drawing.Point(168, 513);
            this.txttenkhoanmuc3.Name = "txttenkhoanmuc3";
            this.txttenkhoanmuc3.Size = new System.Drawing.Size(296, 20);
            this.txttenkhoanmuc3.TabIndex = 19;
            this.txttenkhoanmuc3.Visible = false;
            // 
            // txtkhoanmuc3
            // 
            this.txtkhoanmuc3.Enabled = false;
            this.txtkhoanmuc3.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtkhoanmuc3.Location = new System.Drawing.Point(104, 513);
            this.txtkhoanmuc3.Name = "txtkhoanmuc3";
            this.txtkhoanmuc3.Size = new System.Drawing.Size(63, 20);
            this.txtkhoanmuc3.TabIndex = 18;
            this.txtkhoanmuc3.Visible = false;
            this.txtkhoanmuc3.DoubleClick += new System.EventHandler(this.txtkhoanmuc3_DoubleClick);
            this.txtkhoanmuc3.TextChanged += new System.EventHandler(this.txtkhoanmuc3_TextChanged);
            this.txtkhoanmuc3.Validated += new System.EventHandler(this.txtkhoanmuc3_Validated);
            this.txtkhoanmuc3.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtkhoanmuc3_KeyDown);
            this.txtkhoanmuc3.Enter += new System.EventHandler(this.txtkhoanmuc3_Enter);
            // 
            // txttenkhoanmuc2
            // 
            this.txttenkhoanmuc2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txttenkhoanmuc2.Enabled = false;
            this.txttenkhoanmuc2.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenkhoanmuc2.Location = new System.Drawing.Point(168, 489);
            this.txttenkhoanmuc2.Name = "txttenkhoanmuc2";
            this.txttenkhoanmuc2.Size = new System.Drawing.Size(296, 20);
            this.txttenkhoanmuc2.TabIndex = 17;
            this.txttenkhoanmuc2.Visible = false;
            // 
            // txtkhoanmuc2
            // 
            this.txtkhoanmuc2.Enabled = false;
            this.txtkhoanmuc2.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtkhoanmuc2.Location = new System.Drawing.Point(104, 489);
            this.txtkhoanmuc2.Name = "txtkhoanmuc2";
            this.txtkhoanmuc2.Size = new System.Drawing.Size(63, 20);
            this.txtkhoanmuc2.TabIndex = 16;
            this.txtkhoanmuc2.Visible = false;
            this.txtkhoanmuc2.DoubleClick += new System.EventHandler(this.txtkhoanmuc2_DoubleClick);
            this.txtkhoanmuc2.TextChanged += new System.EventHandler(this.txtkhoanmuc2_TextChanged);
            this.txtkhoanmuc2.Validated += new System.EventHandler(this.txtkhoanmuc2_Validated);
            this.txtkhoanmuc2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtkhoanmuc2_KeyDown);
            this.txtkhoanmuc2.Enter += new System.EventHandler(this.txtkhoanmuc2_Enter);
            // 
            // lblkhoanmuc4
            // 
            this.lblkhoanmuc4.Enabled = false;
            this.lblkhoanmuc4.Location = new System.Drawing.Point(22, 534);
            this.lblkhoanmuc4.Name = "lblkhoanmuc4";
            this.lblkhoanmuc4.Size = new System.Drawing.Size(80, 23);
            this.lblkhoanmuc4.TabIndex = 10;
            this.lblkhoanmuc4.Text = "Khoản mục 4:";
            this.lblkhoanmuc4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.lblkhoanmuc4.Visible = false;
            // 
            // lblkhoanmuc3
            // 
            this.lblkhoanmuc3.Enabled = false;
            this.lblkhoanmuc3.Location = new System.Drawing.Point(24, 513);
            this.lblkhoanmuc3.Name = "lblkhoanmuc3";
            this.lblkhoanmuc3.Size = new System.Drawing.Size(80, 23);
            this.lblkhoanmuc3.TabIndex = 9;
            this.lblkhoanmuc3.Text = "Khoản mục 3:";
            this.lblkhoanmuc3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.lblkhoanmuc3.Visible = false;
            // 
            // lblkhoanmuc2
            // 
            this.lblkhoanmuc2.Enabled = false;
            this.lblkhoanmuc2.Location = new System.Drawing.Point(20, 490);
            this.lblkhoanmuc2.Name = "lblkhoanmuc2";
            this.lblkhoanmuc2.Size = new System.Drawing.Size(80, 23);
            this.lblkhoanmuc2.TabIndex = 8;
            this.lblkhoanmuc2.Text = "Khoản mục 2:";
            this.lblkhoanmuc2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.lblkhoanmuc2.Visible = false;
            // 
            // listdoituong
            // 
            this.listdoituong.BackColor = System.Drawing.SystemColors.Info;
            this.listdoituong.ColumnCount = 0;
            this.listdoituong.Location = new System.Drawing.Point(168, 120);
            this.listdoituong.MatchBufferTimeOut = 1000;
            this.listdoituong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listdoituong.Name = "listdoituong";
            this.listdoituong.Size = new System.Drawing.Size(75, 17);
            this.listdoituong.TabIndex = 6;
            this.listdoituong.TextIndex = -1;
            this.listdoituong.TextMember = null;
            this.listdoituong.ValueIndex = -1;
            this.listdoituong.Visible = false;
            // 
            // butExcel
            // 
            this.butExcel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.butExcel.BackColor = System.Drawing.SystemColors.Control;
            this.butExcel.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butExcel.Image = ((System.Drawing.Image)(resources.GetObject("butExcel.Image")));
            this.butExcel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butExcel.Location = new System.Drawing.Point(175, 292);
            this.butExcel.Name = "butExcel";
            this.butExcel.Size = new System.Drawing.Size(60, 25);
            this.butExcel.TabIndex = 5;
            this.butExcel.Text = "&Excel";
            this.butExcel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butExcel.UseVisualStyleBackColor = false;
            this.butExcel.Click += new System.EventHandler(this.butExcel_Click);
            // 
            // butKetthuc
            // 
            this.butKetthuc.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.butKetthuc.BackColor = System.Drawing.SystemColors.Control;
            this.butKetthuc.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butKetthuc.Image = ((System.Drawing.Image)(resources.GetObject("butKetthuc.Image")));
            this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butKetthuc.Location = new System.Drawing.Point(299, 292);
            this.butKetthuc.Name = "butKetthuc";
            this.butKetthuc.Size = new System.Drawing.Size(68, 25);
            this.butKetthuc.TabIndex = 7;
            this.butKetthuc.Text = "&Kết thúc";
            this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butKetthuc.UseVisualStyleBackColor = false;
            this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
            // 
            // butIn
            // 
            this.butIn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.butIn.BackColor = System.Drawing.SystemColors.Control;
            this.butIn.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butIn.Image = ((System.Drawing.Image)(resources.GetObject("butIn.Image")));
            this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butIn.Location = new System.Drawing.Point(237, 292);
            this.butIn.Name = "butIn";
            this.butIn.Size = new System.Drawing.Size(60, 25);
            this.butIn.TabIndex = 6;
            this.butIn.Text = "     &In";
            this.butIn.UseVisualStyleBackColor = false;
            // 
            // butXem
            // 
            this.butXem.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.butXem.BackColor = System.Drawing.SystemColors.Control;
            this.butXem.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butXem.Image = ((System.Drawing.Image)(resources.GetObject("butXem.Image")));
            this.butXem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butXem.Location = new System.Drawing.Point(113, 292);
            this.butXem.Name = "butXem";
            this.butXem.Size = new System.Drawing.Size(60, 25);
            this.butXem.TabIndex = 4;
            this.butXem.Text = "     &Xem";
            this.butXem.UseVisualStyleBackColor = false;
            this.butXem.Click += new System.EventHandler(this.butXem_Click);
            // 
            // listchuong
            // 
            this.listchuong.BackColor = System.Drawing.SystemColors.Info;
            this.listchuong.ColumnCount = 0;
            this.listchuong.Location = new System.Drawing.Point(168, 168);
            this.listchuong.MatchBufferTimeOut = 1000;
            this.listchuong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listchuong.Name = "listchuong";
            this.listchuong.Size = new System.Drawing.Size(75, 17);
            this.listchuong.TabIndex = 131;
            this.listchuong.TextIndex = -1;
            this.listchuong.TextMember = null;
            this.listchuong.ValueIndex = -1;
            this.listchuong.Visible = false;
            // 
            // listtaikhoan
            // 
            this.listtaikhoan.BackColor = System.Drawing.SystemColors.Info;
            this.listtaikhoan.ColumnCount = 0;
            this.listtaikhoan.Location = new System.Drawing.Point(168, 72);
            this.listtaikhoan.MatchBufferTimeOut = 1000;
            this.listtaikhoan.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listtaikhoan.Name = "listtaikhoan";
            this.listtaikhoan.Size = new System.Drawing.Size(75, 17);
            this.listtaikhoan.TabIndex = 5;
            this.listtaikhoan.TextIndex = -1;
            this.listtaikhoan.TextMember = null;
            this.listtaikhoan.ValueIndex = -1;
            this.listtaikhoan.Visible = false;
            // 
            // listloaikhoan
            // 
            this.listloaikhoan.BackColor = System.Drawing.SystemColors.Info;
            this.listloaikhoan.ColumnCount = 0;
            this.listloaikhoan.Location = new System.Drawing.Point(168, 216);
            this.listloaikhoan.MatchBufferTimeOut = 1000;
            this.listloaikhoan.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listloaikhoan.Name = "listloaikhoan";
            this.listloaikhoan.Size = new System.Drawing.Size(75, 17);
            this.listloaikhoan.TabIndex = 134;
            this.listloaikhoan.TextIndex = -1;
            this.listloaikhoan.TextMember = null;
            this.listloaikhoan.ValueIndex = -1;
            this.listloaikhoan.Visible = false;
            // 
            // listhoatdong
            // 
            this.listhoatdong.BackColor = System.Drawing.SystemColors.Info;
            this.listhoatdong.ColumnCount = 0;
            this.listhoatdong.Location = new System.Drawing.Point(168, 192);
            this.listhoatdong.MatchBufferTimeOut = 1000;
            this.listhoatdong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listhoatdong.Name = "listhoatdong";
            this.listhoatdong.Size = new System.Drawing.Size(75, 17);
            this.listhoatdong.TabIndex = 135;
            this.listhoatdong.TextIndex = -1;
            this.listhoatdong.TextMember = null;
            this.listhoatdong.ValueIndex = -1;
            this.listhoatdong.Visible = false;
            // 
            // listkhoanmuc2
            // 
            this.listkhoanmuc2.BackColor = System.Drawing.SystemColors.Info;
            this.listkhoanmuc2.ColumnCount = 0;
            this.listkhoanmuc2.Location = new System.Drawing.Point(175, 514);
            this.listkhoanmuc2.MatchBufferTimeOut = 1000;
            this.listkhoanmuc2.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listkhoanmuc2.Name = "listkhoanmuc2";
            this.listkhoanmuc2.Size = new System.Drawing.Size(75, 17);
            this.listkhoanmuc2.TabIndex = 137;
            this.listkhoanmuc2.TextIndex = -1;
            this.listkhoanmuc2.TextMember = null;
            this.listkhoanmuc2.ValueIndex = -1;
            this.listkhoanmuc2.Visible = false;
            // 
            // listkhoanmuc3
            // 
            this.listkhoanmuc3.BackColor = System.Drawing.SystemColors.Info;
            this.listkhoanmuc3.ColumnCount = 0;
            this.listkhoanmuc3.Location = new System.Drawing.Point(175, 489);
            this.listkhoanmuc3.MatchBufferTimeOut = 1000;
            this.listkhoanmuc3.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listkhoanmuc3.Name = "listkhoanmuc3";
            this.listkhoanmuc3.Size = new System.Drawing.Size(75, 17);
            this.listkhoanmuc3.TabIndex = 138;
            this.listkhoanmuc3.TextIndex = -1;
            this.listkhoanmuc3.TextMember = null;
            this.listkhoanmuc3.ValueIndex = -1;
            this.listkhoanmuc3.Visible = false;
            // 
            // listkhoanmuc4
            // 
            this.listkhoanmuc4.BackColor = System.Drawing.SystemColors.Info;
            this.listkhoanmuc4.ColumnCount = 0;
            this.listkhoanmuc4.Location = new System.Drawing.Point(173, 537);
            this.listkhoanmuc4.MatchBufferTimeOut = 1000;
            this.listkhoanmuc4.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listkhoanmuc4.Name = "listkhoanmuc4";
            this.listkhoanmuc4.Size = new System.Drawing.Size(75, 17);
            this.listkhoanmuc4.TabIndex = 139;
            this.listkhoanmuc4.TextIndex = -1;
            this.listkhoanmuc4.TextMember = null;
            this.listkhoanmuc4.ValueIndex = -1;
            this.listkhoanmuc4.Visible = false;
            // 
            // listnhombc
            // 
            this.listnhombc.BackColor = System.Drawing.SystemColors.Info;
            this.listnhombc.ColumnCount = 0;
            this.listnhombc.Location = new System.Drawing.Point(168, 144);
            this.listnhombc.MatchBufferTimeOut = 1000;
            this.listnhombc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listnhombc.Name = "listnhombc";
            this.listnhombc.Size = new System.Drawing.Size(75, 17);
            this.listnhombc.TabIndex = 147;
            this.listnhombc.TextIndex = -1;
            this.listnhombc.TextMember = null;
            this.listnhombc.ValueIndex = -1;
            this.listnhombc.Visible = false;
            // 
            // grbNgay
            // 
            this.grbNgay.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grbNgay.Controls.Add(this.dtpDenngay);
            this.grbNgay.Controls.Add(this.lblDenngay);
            this.grbNgay.Controls.Add(this.dtpTungay);
            this.grbNgay.Controls.Add(this.lblTungay);
            this.grbNgay.Location = new System.Drawing.Point(104, 0);
            this.grbNgay.Name = "grbNgay";
            this.grbNgay.Size = new System.Drawing.Size(368, 36);
            this.grbNgay.TabIndex = 1;
            this.grbNgay.TabStop = false;
            // 
            // dtpDenngay
            // 
            this.dtpDenngay.CustomFormat = "dd/MM/yyyy";
            this.dtpDenngay.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dtpDenngay.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
            this.dtpDenngay.Location = new System.Drawing.Point(198, 9);
            this.dtpDenngay.Name = "dtpDenngay";
            this.dtpDenngay.Size = new System.Drawing.Size(80, 21);
            this.dtpDenngay.TabIndex = 3;
            // 
            // lblDenngay
            // 
            this.lblDenngay.BackColor = System.Drawing.SystemColors.Control;
            this.lblDenngay.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblDenngay.Location = new System.Drawing.Point(145, 10);
            this.lblDenngay.Name = "lblDenngay";
            this.lblDenngay.Size = new System.Drawing.Size(51, 23);
            this.lblDenngay.TabIndex = 2;
            this.lblDenngay.Text = "đến ngày";
            this.lblDenngay.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // dtpTungay
            // 
            this.dtpTungay.CustomFormat = "dd/MM/yyyy";
            this.dtpTungay.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dtpTungay.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
            this.dtpTungay.Location = new System.Drawing.Point(64, 9);
            this.dtpTungay.Name = "dtpTungay";
            this.dtpTungay.Size = new System.Drawing.Size(80, 21);
            this.dtpTungay.TabIndex = 1;
            // 
            // lblTungay
            // 
            this.lblTungay.BackColor = System.Drawing.SystemColors.Control;
            this.lblTungay.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblTungay.Location = new System.Drawing.Point(10, 10);
            this.lblTungay.Name = "lblTungay";
            this.lblTungay.Size = new System.Drawing.Size(49, 23);
            this.lblTungay.TabIndex = 0;
            this.lblTungay.Text = "Từ ngày";
            this.lblTungay.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // grbThang
            // 
            this.grbThang.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grbThang.Controls.Add(this.numDenthang);
            this.grbThang.Controls.Add(this.numTuthang);
            this.grbThang.Controls.Add(this.numNam);
            this.grbThang.Controls.Add(this.lblNam);
            this.grbThang.Controls.Add(this.lblDenthang);
            this.grbThang.Controls.Add(this.lblTuthang);
            this.grbThang.Enabled = false;
            this.grbThang.Location = new System.Drawing.Point(104, 24);
            this.grbThang.Name = "grbThang";
            this.grbThang.Size = new System.Drawing.Size(368, 40);
            this.grbThang.TabIndex = 2;
            this.grbThang.TabStop = false;
            // 
            // numDenthang
            // 
            this.numDenthang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.numDenthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.numDenthang.Location = new System.Drawing.Point(148, 15);
            this.numDenthang.Maximum = new decimal(new int[] {
            12,
            0,
            0,
            0});
            this.numDenthang.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numDenthang.Name = "numDenthang";
            this.numDenthang.Size = new System.Drawing.Size(38, 21);
            this.numDenthang.TabIndex = 3;
            this.numDenthang.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            // 
            // numTuthang
            // 
            this.numTuthang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.numTuthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.numTuthang.Location = new System.Drawing.Point(64, 15);
            this.numTuthang.Maximum = new decimal(new int[] {
            12,
            0,
            0,
            0});
            this.numTuthang.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numTuthang.Name = "numTuthang";
            this.numTuthang.Size = new System.Drawing.Size(38, 21);
            this.numTuthang.TabIndex = 1;
            this.numTuthang.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            // 
            // numNam
            // 
            this.numNam.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.numNam.ForeColor = System.Drawing.Color.DarkBlue;
            this.numNam.Location = new System.Drawing.Point(230, 15);
            this.numNam.Maximum = new decimal(new int[] {
            3004,
            0,
            0,
            0});
            this.numNam.Minimum = new decimal(new int[] {
            2004,
            0,
            0,
            0});
            this.numNam.Name = "numNam";
            this.numNam.Size = new System.Drawing.Size(48, 21);
            this.numNam.TabIndex = 5;
            this.numNam.Value = new decimal(new int[] {
            2004,
            0,
            0,
            0});
            // 
            // lblNam
            // 
            this.lblNam.BackColor = System.Drawing.SystemColors.Control;
            this.lblNam.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblNam.Location = new System.Drawing.Point(189, 15);
            this.lblNam.Name = "lblNam";
            this.lblNam.Size = new System.Drawing.Size(34, 23);
            this.lblNam.TabIndex = 4;
            this.lblNam.Text = "năm";
            this.lblNam.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblDenthang
            // 
            this.lblDenthang.BackColor = System.Drawing.SystemColors.Control;
            this.lblDenthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblDenthang.Location = new System.Drawing.Point(108, 15);
            this.lblDenthang.Name = "lblDenthang";
            this.lblDenthang.Size = new System.Drawing.Size(32, 23);
            this.lblDenthang.TabIndex = 2;
            this.lblDenthang.Text = "đến ";
            this.lblDenthang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblTuthang
            // 
            this.lblTuthang.BackColor = System.Drawing.SystemColors.Control;
            this.lblTuthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblTuthang.Location = new System.Drawing.Point(10, 15);
            this.lblTuthang.Name = "lblTuthang";
            this.lblTuthang.Size = new System.Drawing.Size(49, 23);
            this.lblTuthang.TabIndex = 0;
            this.lblTuthang.Text = "Từ tháng";
            this.lblTuthang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // grbchon
            // 
            this.grbchon.Controls.Add(this.rdbTheothang);
            this.grbchon.Controls.Add(this.rdbTheongay);
            this.grbchon.Location = new System.Drawing.Point(8, 0);
            this.grbchon.Name = "grbchon";
            this.grbchon.Size = new System.Drawing.Size(98, 64);
            this.grbchon.TabIndex = 0;
            this.grbchon.TabStop = false;
            // 
            // rdbTheothang
            // 
            this.rdbTheothang.ForeColor = System.Drawing.Color.DarkBlue;
            this.rdbTheothang.Location = new System.Drawing.Point(11, 32);
            this.rdbTheothang.Name = "rdbTheothang";
            this.rdbTheothang.Size = new System.Drawing.Size(79, 24);
            this.rdbTheothang.TabIndex = 1;
            this.rdbTheothang.Text = "Theo tháng";
            this.rdbTheothang.CheckedChanged += new System.EventHandler(this.rdbTheothang_CheckedChanged);
            // 
            // rdbTheongay
            // 
            this.rdbTheongay.Checked = true;
            this.rdbTheongay.ForeColor = System.Drawing.Color.DarkBlue;
            this.rdbTheongay.Location = new System.Drawing.Point(11, 8);
            this.rdbTheongay.Name = "rdbTheongay";
            this.rdbTheongay.Size = new System.Drawing.Size(79, 24);
            this.rdbTheongay.TabIndex = 0;
            this.rdbTheongay.TabStop = true;
            this.rdbTheongay.Text = "Theo ngày";
            this.rdbTheongay.CheckedChanged += new System.EventHandler(this.rdbTheongay_CheckedChanged);
            // 
            // lblError
            // 
            this.lblError.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.lblError.Location = new System.Drawing.Point(0, 400);
            this.lblError.Name = "lblError";
            this.lblError.Size = new System.Drawing.Size(477, 23);
            this.lblError.TabIndex = 24;
            this.lblError.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // listloaidt
            // 
            this.listloaidt.BackColor = System.Drawing.SystemColors.Info;
            this.listloaidt.ColumnCount = 0;
            this.listloaidt.Location = new System.Drawing.Point(168, 96);
            this.listloaidt.MatchBufferTimeOut = 1000;
            this.listloaidt.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listloaidt.Name = "listloaidt";
            this.listloaidt.Size = new System.Drawing.Size(75, 17);
            this.listloaidt.TabIndex = 148;
            this.listloaidt.TextIndex = -1;
            this.listloaidt.TextMember = null;
            this.listloaidt.ValueIndex = -1;
            this.listloaidt.Visible = false;
            // 
            // frmReport_sc
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(480, 329);
            this.Controls.Add(this.listloaidt);
            this.Controls.Add(this.grbNgay);
            this.Controls.Add(this.grbThang);
            this.Controls.Add(this.grbchon);
            this.Controls.Add(this.listnhombc);
            this.Controls.Add(this.listkhoanmuc4);
            this.Controls.Add(this.listkhoanmuc3);
            this.Controls.Add(this.listkhoanmuc2);
            this.Controls.Add(this.txttenkhoanmuc4);
            this.Controls.Add(this.listhoatdong);
            this.Controls.Add(this.txtkhoanmuc4);
            this.Controls.Add(this.listloaikhoan);
            this.Controls.Add(this.txttenkhoanmuc3);
            this.Controls.Add(this.listtaikhoan);
            this.Controls.Add(this.txtkhoanmuc3);
            this.Controls.Add(this.txttenkhoanmuc2);
            this.Controls.Add(this.listchuong);
            this.Controls.Add(this.txtkhoanmuc2);
            this.Controls.Add(this.listdoituong);
            this.Controls.Add(this.butExcel);
            this.Controls.Add(this.butKetthuc);
            this.Controls.Add(this.butIn);
            this.Controls.Add(this.butXem);
            this.Controls.Add(this.lblError);
            this.Controls.Add(this.lblkhoanmuc2);
            this.Controls.Add(this.lblkhoanmuc3);
            this.Controls.Add(this.lblkhoanmuc4);
            this.Controls.Add(this.grpNen);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "frmReport_sc";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Load += new System.EventHandler(this.frmReport_yc_Load);
            this.Click += new System.EventHandler(this.frmReport_yc_Click);
            this.grpNen.ResumeLayout(false);
            this.grpNen.PerformLayout();
            this.grbNgay.ResumeLayout(false);
            this.grbThang.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.numDenthang)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numTuthang)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numNam)).EndInit();
            this.grbchon.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion		
		
		private void txttenmuc_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void txtsotaikhoan_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtsotaikhoan && dt_Dmtk!=null)
			{
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listtaikhoan,txtsotaikhoan.Text.Trim(),"ma","ten");						
						listtaikhoan.BrowseToDmtk(txtsotaikhoan,txttentaikhoan,txtloaidt,txtsotaikhoan.Location.X+8,88,txtsotaikhoan.Width+0+txttentaikhoan.Width,txtsotaikhoan.Height+10,100);
						break;
					case "SCTGS":
						Filter_List(listtaikhoan,txtsotaikhoan.Text.Trim(),"ma","ten");
						listtaikhoan.BrowseToDmtk(txtsotaikhoan,txttentaikhoan,txtloaidt,txtsotaikhoan.Location.X+8,88,txtsotaikhoan.Width+0+txttentaikhoan.Width,txtsotaikhoan.Height+10,100);
						break;
					default:
						Filter_List(listtaikhoan,txtsotaikhoan.Text.Trim(),"stk","");						
						listtaikhoan.BrowseToDmtk(txtsotaikhoan,txttentaikhoan,txtloaidt,txtsotaikhoan.Location.X+8,88,txtsotaikhoan.Width+txttentaikhoan.Width+2,txtsotaikhoan.Height,100);					
						break;
				}
			}	
		}

		private void txtsotaikhoan_Validated(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SDKCTGS" || s_Tenform=="SCTGS") s_Maubaocao="SCTGS";
			if (s_Tenform=="SCMUC" || s_Tenform=="") s_Maubaocao="SKMUC";

			txttentaikhoan.Text="";
			if (txtsotaikhoan.Text!="")
			{
				switch (s_Maubaocao)
				{
					case "SCTGS":
						r=a.getrowbyid(dt_Dmtk,"ma='"+txtsotaikhoan.Text.Trim()+"'");
						if (r!=null) 
						{
							txttentaikhoan.Text=r["ten"].ToString();
							txtmuc.Text=""; txttenmuc.Text="";
							b_Lctu=false;
						}
						break;
					case "SKMUC":
						r=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'");
						if (r!=null) 
						{
							txttentaikhoan.Text=r["ttk"].ToString();
							txtkhoanmuc1.Text=""; txttenkhoanmuc1.Text=""; b_Khoanmuc=false;
							txtkhoanmuc2.Text="";txttenkhoanmuc2.Text="";b_Khoanmuc2=false;
							txtkhoanmuc3.Text="";txttenkhoanmuc3.Text="";b_Khoanmuc3=false;
							txtkhoanmuc4.Text="";txttenkhoanmuc4.Text="";b_Khoanmuc4=false;
							txtmuc.Text="";txttenmuc.Text="";b_Muc=false;

						}
						break;
					default:
						r=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'");
						if (r!=null) 
						{
							txttentaikhoan.Text=r["ttk"].ToString();
						}
						break;
				}
			}
			try
			{
				if (lblkhoanmuc1.Visible){ txtkhoanmuc1.Text=""; txttenkhoanmuc1.Text=""; b_Khoanmuc=false; }
				if (lblkhoanmuc2.Visible){ txtkhoanmuc2.Text=""; txttenkhoanmuc2.Text=""; b_Khoanmuc2=false; }
				if (lblkhoanmuc3.Visible){ txtkhoanmuc3.Text=""; txttenkhoanmuc3.Text=""; b_Khoanmuc3=false; }
				if (lblkhoanmuc4.Visible){ txtkhoanmuc4.Text=""; txttenkhoanmuc4.Text=""; b_Khoanmuc4=false; }
				if (lblmuc.Visible){ txtmuc.Text=""; txttenmuc.Text=""; b_Muc=false; }
			}
			catch{}
			hide_List();
		}
		private void txtsotaikhoan_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmtk!=null)
			{
				listtaikhoan.Focus();
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listtaikhoan,txtsotaikhoan.Text.Trim(),"ma","ten");
						listtaikhoan.BrowseToDmtk(txtsotaikhoan,txttentaikhoan,txtloaidt,txtsotaikhoan.Location.X+8,88,txtsotaikhoan.Width+0+txttentaikhoan.Width,txtsotaikhoan.Height+10,100);
						break;
					case "SCTGS":
						Filter_List(listtaikhoan,txtsotaikhoan.Text.Trim(),"ma","ten");
						listtaikhoan.BrowseToDmtk(txtsotaikhoan,txttentaikhoan,txtloaidt,txtsotaikhoan.Location.X+8,88 ,txtsotaikhoan.Width+0+txttentaikhoan.Width,txtsotaikhoan.Height+10,100);
						break;
					default:
						Filter_List(listtaikhoan,txtsotaikhoan.Text.Trim(),"stk","");
						listtaikhoan.BrowseToDmtk(txtsotaikhoan,txttentaikhoan,txtloaidt,txtsotaikhoan.Location.X+8,88,txtsotaikhoan.Width+txttentaikhoan.Width+2,txtsotaikhoan.Height,100);
						break;
				}
			}
		}
		private void Filter_List(LibList.List listDulieu,string s_Dkloc,string s_Tenfield_1,string s_Tenfield_2)
		{
			try
			{
				string s_Dieukien=s_Tenfield_1.Trim()+" like '%"+s_Dkloc.Trim()+"%'";
				if (s_Tenfield_2.Trim()!="") s_Dieukien+=" or "+s_Tenfield_2.Trim()+" like '%"+s_Dkloc.Trim()+"%'";
				CurrencyManager cm= (CurrencyManager)BindingContext[listDulieu.DataSource];
				System.Data.DataView dv=(System.Data.DataView)cm.List;
				dv.RowFilter=s_Dieukien;
			}
			catch{}
		}
		#region ham khoi tao
		private void hide_List()
		{
			if(!listtaikhoan.Focused) listtaikhoan.Hide();
			if(!listloaikhoan.Focused) listloaikhoan.Hide();
			if(!listmuc.Focused)listmuc.Hide();
			if(!listchuong.Focused)listchuong.Hide();
			if(!listhoatdong.Focused)listhoatdong.Hide();
			if(!listnhombc.Focused)listnhombc.Hide();
			if(!listloaidt.Focused)listloaidt.Hide();
			if(!listdoituong.Focused)listdoituong.Hide();
			if(!listkhoanmuc1.Focused)listkhoanmuc1.Hide();
			if(!listkhoanmuc2.Focused)listkhoanmuc2.Hide();
			if(!listkhoanmuc3.Focused)listkhoanmuc3.Hide();
			if(!listkhoanmuc4.Focused)listkhoanmuc4.Hide();
		}
		private void f_Loaddm()
		{
			f_LoadHoatdong();	
			if (txtsotaikhoan.Text!="") f_LoadLoaictu(ref listmuc,ref dt_Dmmuc,txtsotaikhoan.Text.Trim());
			f_LoadLoaiDoituong();			
			f_LoadChuong();
			f_LoadNhombc();
			f_LoadLoaikhoan();

			string s_Danhmuc=s_Tenform;
			//tat ca cac form tru cac form lien quan den tien mat cho load het dmtk
			if (s_Tenform=="SQTM1" ||s_Tenform=="SQTMCT") s_Danhmuc="TM"; 			
			if (s_Tenform=="TGNHCT" ||s_Tenform=="TGNHTH") s_Danhmuc="STGNH"; 	
			if(s_Tenform=="SCTTK"||s_Tenform=="SCTTK_M2") s_Danhmuc="SCTTK";
            if (s_Tenform == "SOHANGMUCKINHPHI") s_Danhmuc = "HMKP";
			switch (s_Danhmuc)
			{
				case "TM":					
					cbobctheo.Left=cbochon.Location.X;
					cbobctheo.Width=txtsotaikhoan.Width+txttentaikhoan.Width+2;
					dt_Dmtk=a.get_DMTaikhoan("111").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
                case "HMKP":
                    cbobctheo.Left = cbochon.Location.X;
                    cbobctheo.Width = txtsotaikhoan.Width + txttentaikhoan.Width + 2;
                    dt_Dmtk = a.get_DMTaikhoan("00").Tables[0];
                    f_LoadTaikhoan(dt_Dmtk);
                    break;  
				case "STGNH":
					cbobctheo.Left=cbochon.Location.X;
					cbobctheo.Width=txtsotaikhoan.Width+txttentaikhoan.Width+2;
					dt_Dmtk=a.get_DMTaikhoan("112").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "BTHCT":
					cbochon.Visible=true;
					f_LoadCbo_Baocaotheo();
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SCTTK": //So chi tiet cac tai khoan.
					//dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					cbobctheo.Left=cbochon.Location.X;
					cbobctheo.Width=txtsotaikhoan.Width+txttentaikhoan.Width+2;
					dt_Dmtk=a.get_DMTaikhoancongno("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "STHCN":
					cbobctheo.Left=cbochon.Location.X;
					cbobctheo.Width=txtsotaikhoan.Width+txttentaikhoan.Width+2;
					dt_Dmtk=a.get_DMTaikhoancongno("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "STDTU":
					cbochon.Visible=true;
					f_LoadKhoaphong();
					dt_Dmtk=a.get_DMTaikhoancongno("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SCTKT":
					cbobctheo.Left=cbochon.Location.X;
					cbobctheo.Width=txtsotaikhoan.Width+txttentaikhoan.Width+2;
					dt_Dmtk=a.get_DMTaikhoan("5").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SoNhatKyThuTien":
					dt_Dmtk=a.get_NhatKyThuChi().Tables[0];	
					f_LoadTaikhoan(dt_Dmtk);
					break;	
				case "SoNhatKyChiTien":
					dt_Dmtk=a.get_NhatKyThuChi().Tables[0];	
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SoNhatKyMuaHang":
					dt_Dmtk=a.get_DMTaikhoan("331").Tables[0];	
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SoNhatKyBanHang":
					try
					{
						dt_Dmtk=a.get_DMTaikhoan("131").Tables[0];	
						f_LoadTaikhoan(dt_Dmtk);
					}
					catch 
					{
						MessageBox.Show("Chưa tạo tài khoản 131! Vào Tiện Ích để cập nhật tài khoản 131!");
					}
					
					break;
				case "SoChiTietS31":
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SoChiPhiSanXuatKD":
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;	
				case "SoChiTietS35":
					dt_Dmtk=a.get_DMTaikhoan("5").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "TongHopTaiKhoanTienGui":
					dt_Dmtk=a.get_DMTaikhoan("112").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SoTongHopChiPhi":
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "SoChiTietChiPhi":
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				case "BKCTGCL":
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
				default:
					cbobctheo.Left=cbochon.Location.X;
					cbobctheo.Width=txtsotaikhoan.Width+txttentaikhoan.Width+2;
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
			}
			//
		}
		private void f_Loadform_SOCHUNGTU(string s_Tieudeform,string s_Filereport,string s_Tieudereport,string s_Giay,int i_In,int i_Soto)
		{
			this.Text=s_Tieudeform;			
			s_Report=s_Filereport;
			i_Kieuin=i_In; i_Banin=i_Soto; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize=s_Giay;
			s_fTieude_chinh=s_Tieudereport;
			f_Dispose_Control(false);
		}		
		private void f_Loadform()
		{	//i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			switch (s_Tenform)
			{			
				case "SQTM1":
					f_Loadform_FORMCHUNG("Sổ quỹ tiền mặt","KT_Soquytienmat_.rpt","SỔ QUỸ TIỀN MẶT","A4",2,1);					
					break;
				case "SQTMCT":
					f_Loadform_FORMCHUNG("Sổ quỹ tiền mặt chi tiết (S07-DN)","KT_Soquytienmatchitiet_.rpt","SỔ QUỸ TIỀN MẶT CHI TIẾT","A4",2,1);					
					break;
				case "SDKCTGS":
					f_Loadform_SOCHUNGTU("Sổ đăng ký chứng từ ghi sổ","KT_Sodangkychungtu.rpt","SỔ ĐĂNG KÝ CHỨNG TỪ GHI SỔ","A4",1,1);					
					break;
				case "SCTGS":
					f_Loadform_SOCHUNGTU("Chứng từ ghi sổ","KT_Chungtughiso.rpt","CHỨNG TỪ GHI SỔ","A4",1,1);					
					break;
				case "BTHCT":
					f_Loadform_FORMCHUNG("Bảng tổng hợp chứng từ","KT_Bangtonghopchungtu_.rpt","BẢNG TỔNG HỢP CHỨNG TỪ","A4",2,1);					
					break;
				case "SCTH":
					f_Loadform_FORMCHUNG("Sổ cái tổng hợp","KT_rSocaiTH_.rpt","SỔ CÁI TỔNG HỢP","A4",2,1);					
					break;
				case "SOCAI_S3b":
                    f_Loadform_FORMCHUNG("Sổ cái S3b - H (Dùng cho hình thức kế toán nhật ký chung) ", "KT_rSoCai_.rpt", "Sổ cái S3b - H (Dùng cho hình thức kế toán nhật ký chung)", "A4", 2, 1);					
					break;
                case "SOHANGMUCKINHPHI":
                    f_Loadform_FORMCHUNG("Sổ theo dõi hạng mức kinh phí ", "KT_rSoHangMucKinhPhi.rpt", "SỔ THEO DÕI HẠNG MỨC KINH PHÍ", "A4", 2, 1);
                    break;
				case "TGNHCT":
					f_Loadform_FORMCHUNG("Sổ tiền gởi ngân hàng chi tiết","KT_Sotienguinganhang_.rpt","SỔ TIỀN GỬI NGÂN HÀNG","A4",2,1);					
					break;
				case "TGNHTH":
					f_Loadform_FORMCHUNG("Sổ tiền gởi ngân hàng tổng hợp","KT_Sotienguinganhang_th_.rpt","SỔ TIỀN GỬI NGÂN HÀNG","A4",2,1);					
					break;
				case "SCTTK": //So chi tiet cac tai khoan (S33 - H)
					f_Loadform_FORMCHUNG("Sổ chi tiết các tài khoản (Tài khoản công nợ)","KT_Soctcactaikhoan_.rpt","SỔ CHI TIẾT CÁC TÀI KHOẢN (TK CÔNG NỢ)","A4",2,1);					
					break;
				case "SCTTK_M2": //So chi tiet cac tai khoan mau 2 (S33 - H)
					f_Loadform_FORMCHUNG("Sổ chi tiết các tài khoản","KT_Soctcactaikhoan_m2_.rpt","SỔ CHI TIẾT CÁC TÀI KHOẢN","A4",2,1);					
					break;
				case "SCTTK_": //So chi tiet cac tai khoan (S33 - H)
					f_Loadform_FORMCHUNG("Sổ chi tiết các tài khoản","KT_Soctmoitaikhoan_.rpt","SỔ CHI TIẾT CÁC TÀI KHOẢN","A4",2,1);					
					break;
				case "STHCN":
					f_Loadform_FORMCHUNG("Sổ tổng hợp công nợ","KT_Tonghopcongno_.rpt","TỔNG HỢP CÔNG NỢ","A4",2,1);					
					break;			
				case "STDTU":
					f_Loadform_FORMCHUNG("Sổ theo dõi tạm ứng","KT_Sotheodoitamung_.rpt","SỔ THEO DÕI TẠM ỨNG","A4",2,1);					
					break;		
				case "SCTKT":
					f_Loadform_FORMCHUNG("Sổ chi tiết các khoản thu","KT_Soctcackhoanthu_.rpt","SỔ CHI TIẾT CÁC KHOẢN THU","A4",2,1);					
					break;
				case "SoNhatKyThuTien":
					f_Loadform1();
					break;	
				case "SoNhatKyChiTien":
					f_Loadform1();
					break;
				case "SoNhatKyMuaHang":
					f_Loadform1();
					break;
				case "SoNhatKyBanHang":
					f_Loadform1();
					break;
				case "SoChiTietS31":
					f_Loadform2();
					break;
				case "SoChiTietS32":
					f_Loadform2();
					break;
				case "SoChiTietS34":
					f_Loadform2();
					break;
				case "SoChiTietS35":
					f_Loadform1();
					break;
				case "SoChiPhiSanXuatKD":
					f_Loadform1();
					break;
				case "TongHopTaiKhoanTienGui":
					numDenthang.Value = 1;
					f_Loadform1();
					break;
				case "SoTongHopChiPhi":
					f_Loadform3();
					break;
				case "SoChiTietChiPhi":
					f_Loadform3();
					break;
				case "BKCTGCL":
					f_Loadform1();
					break;
				default:
					f_Loadform_Null();
					break;
			}
		}

		private void f_Loadform1()
		{
			try
			{
				this.Height = 209;
				this.Width = 488;				
				butIn.Left = 241;butIn.Top = 114;
				butXem.Left = 100;	butXem.Top = 114;
				butKetthuc.Left = 312;butKetthuc.Top = 114;
				butExcel.Left = 170;butExcel.Top = 114;
				grpNen.Left = 8;grpNen.Top = 56;
				grpNen.Height = 48;grpNen.Width = 464;
				lbltaikhoan.Left = 8;lbltaikhoan.Top=16;
				txtsotaikhoan.Left = 88;txtsotaikhoan.Top = 16;
				txttentaikhoan.Left = 152;txttentaikhoan.Top = 16;

				lblloaidt.Visible = false; txtloaidt.Visible = false;txttenloaidt.Visible = false;
				lbldoituong.Visible = false;txtdoituong.Visible = false;txttendoituong.Visible = false;
				lblkhoanmuc1.Visible = false;txtkhoanmuc1.Visible = false;txttenkhoanmuc1.Visible = false;
				lblnhombc.Visible = false;txtnhombc.Visible = false;txttennhombc.Visible = false;
				lblchuong.Visible = false;txtchuong.Visible = false;txttenchuong.Visible = false;
				lblhoatdong.Visible = false;txthoatdong.Visible = false;txttenhoatdong.Visible = false;
				lblloaikhoan.Visible = false;txtloaikhoan.Visible = false;txttenloaikhoan.Visible = false;
				lblmuc.Visible = false;txtmuc.Visible = false;txttenmuc.Visible = false;
				lblkhoanmuc1.Visible = false;txtkhoanmuc1.Visible = false;txttenkhoanmuc1.Visible = false;
				lblkhoanmuc2.Visible = false;txtkhoanmuc2.Visible = false;txttenkhoanmuc2.Visible = false;
				lblkhoanmuc3.Visible = false;txtkhoanmuc3.Visible = false;txttenkhoanmuc3.Visible = false;
				lblkhoanmuc4.Visible = false;txtkhoanmuc4.Visible = false;txttenkhoanmuc4.Visible = false;
				lblbctheo.Visible = false;cbobctheo.Visible = false;cbochon.Visible = false;						
				grbchon.Enabled=true;grbNgay.Enabled=true;grbThang.Enabled=true;
				
				switch (s_Tenform)
				{
					case "SoNhatKyThuTien":
						this.Text="Sổ Nhật Ký Thu Tiền";				
						s_Report="KT_SoNhatKyThuTien.rpt";
						break;
					case "SoNhatKyChiTien":
						this.Text="Sổ Nhật Ký Chi Tiền";				
						s_Report="KT_SoNhatKyChiTien.rpt";
						break;
					case "SoNhatKyMuaHang":
						this.Text="Sổ Nhật Ký Mua Hàng";				
						s_Report="KT_SoNhatKyMuaHang.rpt";
						break;
					case "SoNhatKyBanHang":
						this.Text="Sổ Nhật Ký Bán Hàng";				
						s_Report="KT_SoNhatKyBanHang.rpt";
						break;
					case "SoChiTietS35":
						this.Text="Sổ Chi Tiết Bán Hàng";				
						s_Report="KT_SoChiTietBanHang.rpt";
						break;
					case "SoChiPhiSanXuatKD":
						this.Text="Sổ Chi Phí Sản Xuất - Kinh Doanh";				
						s_Report="KT_ChiPhiSanXuatKinhDoanh.rpt";
						break;
					case "TongHopTaiKhoanTienGui":
						this.Text="Sổ Tổng Hợp Tài Khoản Tiền Gửi";	
						lblTuthang.Enabled = false; numTuthang.Enabled = false;
						lblDenthang.Text = "Quý ";
						numDenthang.Maximum = 4;
						s_Report="KT_TongHopTaiKhoanTienGui.rpt";
						break;
					case "BKCTGCL":
						lblnhombc.Visible = true;
						txtnhombc.Visible = true;
						txttennhombc.Visible = true;
						grpNen.Height = 68;grpNen.Width = 464;
						lblnhombc.Left = 8;lblnhombc.Top=36;
						txtnhombc.Left = 88;txtnhombc.Top = 36;
						txttennhombc.Left = 152;txttennhombc.Top = 36;
						butIn.Left = 241;butIn.Top = 134;
						butXem.Left = 100;	butXem.Top = 134;
						butKetthuc.Left = 312;butKetthuc.Top = 134;
						butExcel.Left = 170;butExcel.Top = 134;
						grbchon.Enabled=true;grbNgay.Enabled=true;
						this.Text="Bảng kê chứng từ gốc cùng loại";
						s_Report="KT_Bangtonghopchungtu_.rpt";
						break;
				}
				

			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
		}


		private void f_Loadform2()
		{
			try
			{
				this.Height = 272;this.Width = 488;				
				butIn.Left = 241;butIn.Top = 210;
				butXem.Left = 100;	butXem.Top = 210;
				butKetthuc.Left = 312;butKetthuc.Top = 210;
				butExcel.Left = 170;butExcel.Top = 210;
				grpNen.Left = 8;grpNen.Top = 56;
				grpNen.Height = 144;grpNen.Width = 464;
				lbltaikhoan.Left = 8;lbltaikhoan.Top=16;txtsotaikhoan.Left = 88;txtsotaikhoan.Top = 16;	txttentaikhoan.Left = 152;txttentaikhoan.Top = 16;
				lblloaidt.Left = 8;lblloaidt.Top=40;txtloaidt.Left = 88;txtloaidt.Top = 40;txttenloaidt.Left = 152;txttenloaidt.Top = 40;
				lbldoituong.Left = 8;lbldoituong.Top=64;txtdoituong.Left = 88;txtdoituong.Top = 64;txttendoituong.Left = 152;txttendoituong.Top = 64;
				lblkhoanmuc1.Left = 8;lblkhoanmuc1.Top=88;txtkhoanmuc1.Left = 88;txtkhoanmuc1.Top = 88;txttenkhoanmuc1.Left = 152;txttenkhoanmuc1.Top = 88;
				//lblNgoaite.Left = 8;lblNgoaite.Top=112;ngoaite.Left = 88;ngoaite.Top = 112;
				lblkhoanmuc1.Text = "Khoản mục :";
				lblloaidt.Visible = true; txtloaidt.Visible = true;txttenloaidt.Visible = true;
				lbldoituong.Visible = true;txtdoituong.Visible = true;txttendoituong.Visible = true;
				lblnhombc.Visible = false;txtnhombc.Visible = false;txttennhombc.Visible = false;
				lblchuong.Visible = false;txtchuong.Visible = false;txttenchuong.Visible = false;
				lblhoatdong.Visible = false;txthoatdong.Visible = false;txttenhoatdong.Visible = false;
				lblloaikhoan.Visible = false;txtloaikhoan.Visible = false;txttenloaikhoan.Visible = false;
				lblmuc.Visible = false;txtmuc.Visible = false;txttenmuc.Visible = false;
				lblkhoanmuc1.Visible = false;txtkhoanmuc1.Visible = false;txttenkhoanmuc1.Visible = false;
				lblkhoanmuc2.Visible = false;txtkhoanmuc2.Visible = false;txttenkhoanmuc2.Visible = false;
				lblkhoanmuc3.Visible = false;txtkhoanmuc3.Visible = false;txttenkhoanmuc3.Visible = false;
				lblkhoanmuc4.Visible = false;txtkhoanmuc4.Visible = false;txttenkhoanmuc4.Visible = false;
				lblbctheo.Visible = false;cbobctheo.Visible = false;cbochon.Visible = false;		
				//lblNgoaite.Visible = true;ngoaite.Visible = true;
				grbchon.Enabled=false;grbNgay.Enabled=false;grbThang.Enabled=true;;
				
				switch (s_Tenform)
				{
					case "SoChiTietS31":
						//lblNgoaite.Enabled = false;
						//ngoaite.Enabled=false;
						this.Text="Sổ Chi Tiết Thanh Toán Với Người Mua (Người Bán) (S31-DN)";				
						s_Report="KT_SoChiTietS31.rpt";
						break;
//					case "SoChiTietS32":
//						//lblNgoaite.Enabled = true;
//						//ngoaite.Enabled=true;
//						this.Text="Sổ Chi Tiết Thanh Toán Với Người Mua (Người Bán)Bằng Ngoại Tệ (S32-DN)";				
//						s_Report="KT_SoChiTietS32.rpt";
//						break;						
					case "SoChiTietS34":
						//lblNgoaite.Enabled = false;
						//ngoaite.Enabled=false;
						this.Text="Sổ Chi Tiết Tiền Vay (S34-DN)";				
						s_Report="KT_SoChiTietS34.rpt";
						break;	
				}
				

			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
		}


		private void f_Loadform3()
		{
			try
			{
				this.Height = 216;this.Width = 488;				
				butIn.Left = 241;butIn.Top = 154;
				butXem.Left = 100;	butXem.Top = 154;
				butKetthuc.Left = 312;butKetthuc.Top = 154;
				butExcel.Left = 170;butExcel.Top = 154;
				grpNen.Left = 8;grpNen.Top = 56;
				grpNen.Height = 72;grpNen.Width = 464;
				lbltaikhoan.Left = 8;lbltaikhoan.Top=16;txtsotaikhoan.Left = 88;txtsotaikhoan.Top = 16;	txttentaikhoan.Left = 152;txttentaikhoan.Top = 16;
				lblkhoanmuc1.Left = 8;lblkhoanmuc1.Top=40;txtkhoanmuc1.Left = 88;txtkhoanmuc1.Top = 40;txttenkhoanmuc1.Left = 152;txttenkhoanmuc1.Top = 40;
				//lbldoituong.Left = 8;lbldoituong.Top=64;txtkhoanmuc1.Left = 88;txtkhoanmuc1.Top = 64;txttenkhoanmuc1.Left = 152;txttenkhoanmuc1.Top = 64;
				//lblkhoanmuc1.Left = 8;lblkhoanmuc1.Top=88;txtkhoanmuc1.Left = 88;txtkhoanmuc1.Top = 88;txttenkhoanmuc1.Left = 152;txttenkhoanmuc1.Top = 88;
				//lblNgoaite.Left = 8;lblNgoaite.Top=112;ngoaite.Left = 88;ngoaite.Top = 112;
				lblkhoanmuc1.Text = "Khoản mục :";
				lblloaidt.Visible = false; txtloaidt.Visible = false;txttenloaidt.Visible = false;
				lbldoituong.Visible = false;txtdoituong.Visible = false;txttendoituong.Visible = false;
				lblnhombc.Visible = false;txtnhombc.Visible = false;txttennhombc.Visible = false;
				lblchuong.Visible = false;txtchuong.Visible = false;txttenchuong.Visible = false;
				lblhoatdong.Visible = false;txthoatdong.Visible = false;txttenhoatdong.Visible = false;
				lblloaikhoan.Visible = false;txtloaikhoan.Visible = false;txttenloaikhoan.Visible = false;
				lblmuc.Visible = false;txtmuc.Visible = false;txttenmuc.Visible = false;
				lblkhoanmuc1.Visible = true;txtkhoanmuc1.Visible = true;txttenkhoanmuc1.Visible = true;
				lblkhoanmuc2.Visible = false;txtkhoanmuc2.Visible = false;txttenkhoanmuc2.Visible = false;
				lblkhoanmuc3.Visible = false;txtkhoanmuc3.Visible = false;txttenkhoanmuc3.Visible = false;
				lblkhoanmuc4.Visible = false;txtkhoanmuc4.Visible = false;txttenkhoanmuc4.Visible = false;
				lblbctheo.Visible = false;cbobctheo.Visible = false;cbochon.Visible = false;		
				//lblNgoaite.Visible = false;ngoaite.Visible = false;
				grbchon.Enabled=false;grbNgay.Enabled=false;grbThang.Enabled=true;;
				
				switch (s_Tenform)
				{
					case "SoTongHopChiPhi":
						//						lblNgoaite.Enabled = false;
						//						ngoaite.Enabled=false;
						this.Text="Sổ Tổng Hợp Chi Phí";				
						s_Report="KT_SoTongHopChiPhi.rpt";
						break;
					case "SoChiTietChiPhi":
						//lblNgoaite.Enabled = true;
						//ngoaite.Enabled=true;
						this.Text="Sổ Chi Tiết Chi Phí";				
						s_Report="KT_SoChiTietChiPhi.rpt";
						break;					
				}
				

			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
		}


		private void f_Loadform_Null()
		{
			this.Text="Báo cáo đang được xây dựng!";
			this.Height=248;
			lblError.Top=50;
			lblError.Left=0;lblError.Text="BÁO CÁO ĐANG XÂY DỰNG!";
			lblError.Visible=true; lblError.BringToFront();
			butKetthuc.Left=206; butKetthuc.Top=160;			
			f_Dispose_Control(true);
		}
		private bool Kiemtra()
		{
			switch (s_Tenform)
			{
				case "SDKCTGS":
					break;
				case "SCTGS":
					break;
				case "SCTTK":
					if (txtsotaikhoan.Text=="")
					{
						MessageBox.Show("Vui lòng nhập số tài khoản!","Chú ý!");
						txtsotaikhoan.Focus();
						return false;
					}
					if (txtdoituong.Text=="")
					{
						MessageBox.Show("Vui lòng nhập tên đối tượng!","Chú ý!");
						txtdoituong.Focus();
						return false;
					}
					break;
				default:
					if (txtsotaikhoan.Text=="")
					{
						MessageBox.Show("Vui lòng nhập số tài khoản!","Chú ý!");
						txtsotaikhoan.Focus();
						return false;
					}
					else
						if(txtloaidt.Text!="")
						if(txtdoituong.Text=="")
						{
							MessageBox.Show("Vui lòng nhập tên đối tượng!","Chú ý!");
							txtdoituong.Focus();
							return false;
						}
					break;
			}
			
			if ((numDenthang.Value<numTuthang.Value)&&(rdbTheothang.Checked))
			{
				MessageBox.Show("Bạn đã chọn từ tháng lớn hơn đến tháng!","Chú ý!");
				numDenthang.Focus();
				return false;
			}
			if (rdbTheongay.Checked)
			{
				if (dtpTungay.Value.Year!=dtpDenngay.Value.Year)
				{
					MessageBox.Show("Bạn chọn số liệu quá nhiều năm!","Chú ý!");
					dtpDenngay.Focus();
					return false;
				}
				if (dtpTungay.Value>dtpDenngay.Value) 
				{
					MessageBox.Show("Bạn đã chọn từ ngày lớn hơn đến ngày!","Chú ý!");
					dtpDenngay.Focus();
					return false;
				}
			}
			return true;
		}

		private void Display(int i_Loai)
			//Loai display: 1 - xuat ra man hinh; 2 - xuat sang excel ; 3 - xuat ra may in. 
		{
			if (Kiemtra()) //Kiem tra dieu kien nhap vao.
			{
				//Gan dieu kien vao cac bien.
				string s_IDtk="",s_IDlk="",s_IDmuc="",s_IDchuong="",s_IDhoatdong="",s_IDnhombc="";
				string s_IDchucnang="", s_IDLoaictu="",s_IDkhoaphong="",s_IDdoituong="",s_IDkhoanmuc="";
				string s_IDkhoanmuc2="",s_IDkhoanmuc3="",s_IDkhoanmuc4="";
				int i_DKgroup=-1;
			
				frmReportPublic_class accMyform=new frmReportPublic_class();
				frmReportNguon_class accMyformNguon=new frmReportNguon_class();
				ds_Data=new System.Data.DataSet();
				//Gan dieu kien ngay thang cho cac bien.				
				int yy=rdbTheongay.Checked?int.Parse(dtpTungay.Value.Year.ToString()):int.Parse(numNam.Value.ToString());
				int mm1=rdbTheongay.Checked?int.Parse(dtpTungay.Value.Month.ToString()):int.Parse(numTuthang.Value.ToString());
				int mm2=rdbTheongay.Checked?int.Parse(dtpDenngay.Value.Month.ToString()):int.Parse(numDenthang.Value.ToString());
				string s_mm=mm1.ToString().PadLeft(2,'0');
				string s_mm2=mm2.ToString().PadLeft(2,'0');
				string s_yyyy=yy.ToString().Trim();
				string s_yy=s_yyyy.Substring(2,2);
				string s_Tungay=rdbTheongay.Checked?dtpTungay.Value.ToString("dd/MM/yyyy"):numTuthang.Value.ToString().PadLeft(2,'0');//+"/"+numNam.Value.ToString().PadLeft(4,'0');
				string s_Denngay=rdbTheongay.Checked?dtpDenngay.Value.ToString("dd/MM/yyyy"):numDenthang.Value.ToString().PadLeft(2,'0');//+"/"+numNam.Value.ToString().PadLeft(4,'0');
				int mm1_ = 0,mm2_ = 0, yy_ = 0;
				frmReport_dn1_class accMyform1 = new frmReport_dn1_class();
				string stk = txtsotaikhoan.Text;
				string ttk = txttentaikhoan.Text;	
				string s_IDloaidoituong = txtloaidt.Text;			
				yy_=int.Parse(numNam.Value.ToString());
				 				
				if (s_Tenform == "TongHopTaiKhoanTienGui")
				{					
					mm2_=int.Parse(numDenthang.Value.ToString());
					mm1_=(mm2_*3)-2;
					mm2_=mm2_*3;
				}
				else
				{
					mm1_=int.Parse(numTuthang.Value.ToString());
					mm2_=int.Parse(numDenthang.Value.ToString());
				}
				string s_mm1_=mm1_.ToString().PadLeft(2,'0');
				string s_mm2_=mm2_.ToString().PadLeft(2,'0');			
				string s_yyyy_=yy_.ToString().Trim();
				string s_yy_=s_yyyy_.Substring(2,2);
				if (mm1_==mm2_)
				{
					ngaythangnam="Tháng " + s_mm1_ + " Năm " + s_yyyy_; 

				}
				else if (s_Tenform == "TongHopTaiKhoanTienGui")
				{										
					ngaythangnam = "Quý " + numDenthang.Value.ToString() + " Năm " + s_yyyy_;
				}
				else
				{
					ngaythangnam="Từ Tháng " + s_mm1_ + " Đến Tháng " + s_mm2_ + " Năm " + s_yyyy_; 
				}

				//Kiem tra va canh bao cac thang chua tinh so du.
				string s_Thangnam=a.kt_Tinhsodu((mm2).ToString(),s_yy);
				if (s_Thangnam!="")
				{
					MessageBox.Show("Các tháng "+s_Thangnam.Substring(0,s_Thangnam.Length-1)+" chưa tính số dư!","Chú ý!");
					//xac minh co tinh so du
					if (MessageBox.Show ("Bạn có muốn kiểm tra số dư không ?",this.Text,MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
					{
						//tinh so du
						string sql="",_tu="",_den="";
						_den=s_mm2+s_yyyy.Substring(2,2);			
						//lay thang tu						
						sql="select mmyy from (select *  from a_dtsd where substr(trim(mmyy),3,4)='"+s_yy+"' order by mmyy asc) where rownum=1";
						DataSet ds=new DataSet();
						ds=a.get_data(sql);
						if(ds!=null && ds.Tables[0].Rows.Count>0)
							_tu=ds.Tables[0].Rows[0]["mmyy"].ToString();
						else _tu=s_mm+s_yyyy.Substring(2,2);			
						if (!a.bYyyy(s_yyyy))
						{
							MessageBox.Show("Số liệu năm "+s_yyyy+" chưa tạo !",a.Msg);
							return;
						}
						string s=a.KiemtraFb(_tu,_den);
						if (s!="")
						{
							MessageBox.Show("Số liệu tháng :"+s.Substring(0,s.Length-1)+" Năm "+s_yyyy+" bị khóa !");    		
							return;
						}
						else 
						{
							Cursor=Cursors.WaitCursor;
							a.KiemtraFb(_tu,_den,i_Iduser);
							Cursor=Cursors.Default;
						}
						//a.updSodu(_tu,a.Mmyy_sau(_den),i_Iduser,false);
						MessageBox.Show("Đã kiểm tra số dư cuối tháng "+_tu.Substring(0,2)+" đến tháng "+_den.Substring(0,2)+" năm 20"+s_yy+" !",a.Msg);					
						//
					}
				}
				try
				{
					if (txtchuong.Text.Trim()!="") s_IDchuong=a.getrowbyid(dt_Dmchuong,"ma='"+txtchuong.Text.Trim()+"'")["id"].ToString().Trim();
					if (txtloaikhoan.Text.Trim()!="") s_IDlk=a.getrowbyid(dt_Dmlk,"lk='"+txtloaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
					if (txttennhombc.Text!="") s_IDnhombc=a.getrowbyid(dt_Dmnhombc,"ma='"+txtnhombc.Text.Trim()+"'")["id"].ToString().Trim();
					if (txthoatdong.Text!="") s_IDhoatdong=a.getrowbyid(dt_Dmhoatdong,"ma='"+txthoatdong.Text.Trim()+"'")["id"].ToString().Trim();
					if(txttenmuc.Text!="") s_IDmuc=a.get_ID_Muc(txtmuc.Text.Trim());//s_IDmuc=a.getrowbyid(dt_Dmmuc,"stk='"+txtmuc.Text.Trim()+"'")["id"].ToString().Trim();
					if (txttendoituong.Text!="") s_IDdoituong=a.getrowbyid(dt_Dmdoituong,"madt='"+txtdoituong.Text.Trim()+"'")["id"].ToString().Trim();
					//if(txttendoituong.Text!="")s_IDdoituong=a.getrowbyid(dt_Dmdoituong,"ma='"+txttendoituong.Text.Trim()+"'")["id"].ToString().Trim();
					if (lblkhoanmuc1.Visible && txtkhoanmuc1.Text.Trim()!="") s_IDkhoanmuc=a.getrowbyid(dt_Dmkhoanmuc1,"ma='"+txtkhoanmuc1.Text.Trim()+"'")["id"].ToString().Trim();
					if (lblkhoanmuc2.Visible && txtkhoanmuc2.Text.Trim()!="") s_IDkhoanmuc2=a.getrowbyid(dt_Dmkhoanmuc2,"ma='"+txtkhoanmuc2.Text.Trim()+"'")["id"].ToString().Trim();					
					if (lblkhoanmuc3.Visible && txtkhoanmuc3.Text.Trim()!="") s_IDkhoanmuc3=a.getrowbyid(dt_Dmkhoanmuc3,"ma='"+txtkhoanmuc3.Text.Trim()+"'")["id"].ToString().Trim();					
					if (lblkhoanmuc4.Visible && txtkhoanmuc4.Text.Trim()!="") s_IDkhoanmuc4=a.getrowbyid(dt_Dmkhoanmuc4,"ma='"+txtkhoanmuc4.Text.Trim()+"'")["id"].ToString().Trim();
					if (cbochon.Visible&&cbochon.Text.Trim()!=""&&s_Tenform=="STDTU") s_IDkhoaphong=a.getrowbyid(dt_Khoaphong,"makp='"+cbochon.SelectedValue.ToString().Trim()+"'")["id"].ToString().Trim();
									
					if(cbobctheo.Text!="")
					{
						i_DKgroup=cbobctheo.SelectedIndex;					
					}
					if(txtsotaikhoan.Text!="") s_sotk=txtsotaikhoan.Text;}
				catch{};
				switch (s_Tenform)
				{
					case "SDKCTGS":
						if (txtsotaikhoan.Text.Trim()!="") s_IDchucnang=a.getrowbyid(dt_Dmtk,"ma='"+txtsotaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
						if (txtmuc.Text.Trim()!="") s_IDLoaictu=a.getrowbyid(dt_Dmmuc,"maso='"+txtmuc.Text.Trim()+"'")["id"].ToString().Trim();
						break;	
					case "SCTGS":
						if (txtsotaikhoan.Text.Trim()!="") s_IDchucnang=a.getrowbyid(dt_Dmtk,"ma='"+txtsotaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
						if (txtmuc.Text.Trim()!="") s_IDLoaictu=a.getrowbyid(dt_Dmmuc,"maso='"+txtmuc.Text.Trim()+"'")["id"].ToString().Trim();
						break;					
					default:
						s_IDtk=a.get_ID_Stk(txtsotaikhoan.Text.Trim());
						if (txthoatdong.Text.Trim()!="") s_IDhoatdong=a.getrowbyid(dt_Dmhoatdong,"ma='"+txthoatdong.Text.Trim()+"'")["id"].ToString().Trim();
						break;
				}
				
				//Load data cua tung mau bao cao.
				switch (s_Tenform)
				{					
					case "SQTM1": //Bao cao So quy tien mat (S07-DN).
						ds_Data=accMyform.f_Soquytienmat(a,s_IDchuong,s_IDdoituong,s_IDmuc,s_IDtk,s_IDlk,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,i_DKgroup);
						accMyform.Dispose();
						break;			
					case "SQTMCT": //Bao cao So quy tien mat (S07-DN).
						ds_Data=accMyform.f_Soquytienmatchitiet(a,s_IDchuong,s_IDdoituong,s_IDmuc,s_IDtk,s_IDlk,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,i_DKgroup);
						accMyform.Dispose();
						break;	
					case "SDKCTGS": //Bao cao So dang ky chung tu ghi so (S02b - H).
						ds_Data=accMyform.f_Sodangkyctughiso(a,s_IDchuong,s_IDchucnang,s_IDLoaictu,s_IDlk,s_IDnhombc,s_Tungay,s_Denngay,s_yy,rdbTheongay.Checked);
						accMyform.Dispose();
						break;
					case "SCTGS": //Bao cao Chung tu ghi so.
						ds_Data=accMyform.f_Sochungtughiso(a,s_IDchuong,s_IDchucnang,s_IDLoaictu,s_IDlk, s_IDtk, s_IDnhombc,s_Tungay,s_Denngay,s_yy,rdbTheongay.Checked);
						accMyform.Dispose();
						break;
					case "SCTH":
						//ds_Data=accMyform.f_SocaiTonghop(a,s_IDchuong,s_IDtk,s_IDlk,s_IDkhoanmuc,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,s_mm,s_mm2,s_yy,s_yyyy,rdbTheongay.Checked,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,s_IDdoituong,s_IDmuc,i_DKgroup);
						ds_Data=accMyformNguon.SoCai_S3b(a,s_IDtk,s_sotk,s_IDlk,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),mm2.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,s_IDchuong,s_IDhoatdong,s_IDnhombc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,s_IDmuc,s_IDdoituong,i_DKgroup,s_Tenform);						
						accMyform.Dispose();
						break;
					case "BTHCT": //Bao cao Bang tong hop chung tu (S01B). 
						ds_Data=accMyform.f_Tonghopchungtu(a,cbochon.SelectedIndex,s_IDchuong,s_IDtk,s_IDlk,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,s_yy,rdbTheongay.Checked,s_IDdoituong,s_IDmuc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					case "SOCAI_S3b":						
						ds_Data=accMyformNguon.SoCai_S3b(a,s_IDtk,s_sotk,s_IDlk,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),mm2.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,s_IDchuong,s_IDhoatdong,s_IDnhombc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,s_IDmuc,s_IDdoituong,i_DKgroup,s_Tenform);						
						accMyform.Dispose();
						break;
                    case "SOHANGMUCKINHPHI":
                        ds_Data = accMyformNguon.SoTheoDoiHangMucKinhPhi(a, s_IDtk, s_sotk, s_IDlk, s_Tungay, s_Denngay, mm1.ToString().PadLeft(2, '0'), mm2.ToString().PadLeft(2, '0'), s_yy, s_yyyy, rdbTheongay.Checked, s_IDchuong, s_IDhoatdong, s_IDnhombc, s_IDkhoanmuc, s_IDkhoanmuc2, s_IDkhoanmuc3, s_IDkhoanmuc4, s_IDmuc, s_IDdoituong, i_DKgroup, s_Tenform);
                        accMyform.Dispose();
                        break;
					case "TGNHCT": //Bao cao So tien gui ngan hang - chi tiet (S08 – DN).
						ds_Data=accMyform.f_Sotienguinganhang(a,s_IDchuong,s_IDtk,s_IDlk,s_IDkhoanmuc,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,s_IDdoituong,s_IDmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					case "TGNHTH": //Bao cao So tien gui ngan hang - tong hop.
						ds_Data=accMyform.f_Sotienguinganhang_th(a,s_IDchuong,s_IDtk,s_IDlk,s_IDkhoanmuc,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,s_IDdoituong,s_IDmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					case "SCTTK": //Bao cao So chi tiet tai khoan.
						int i_Tinhchat=0;
						try {i_Tinhchat=int.Parse(a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["tinhchat"].ToString().Trim());}
						catch{}
						ds_Data=accMyform.f_Sochitiettaikhoan(a,s_IDchuong,s_IDtk,s_sotk,s_IDlk,s_IDhoatdong,s_IDdoituong,s_IDnhombc,i_Tinhchat,s_Tungay,s_Denngay,s_mm,mm1,mm2,s_yy,s_yyyy,rdbTheongay.Checked,s_IDmuc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					case "SCTTK_M2": //Bao cao Tong hop cong no.
						ds_Data=accMyform.f_Sochitiettaikhoan_m2(a,s_IDchuong,s_IDtk,s_IDlk,s_IDhoatdong,s_IDdoituong,s_IDnhombc,0,s_Tungay,s_Denngay,s_mm,mm1,mm2,s_yy,s_yyyy,rdbTheongay.Checked,s_IDmuc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					case "SCTTK_": //Bao cao So chi tiet tai khoan.
						int i_Tinhchat_=0;
						try {i_Tinhchat_=int.Parse(a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["tinhchat"].ToString().Trim());}
						catch{}
						ds_Data=accMyform.f_Sochitiettaikhoan(a,s_IDchuong,s_IDtk,s_sotk,s_IDlk,s_IDhoatdong,s_IDdoituong,s_IDnhombc,i_Tinhchat_,s_Tungay,s_Denngay,s_mm,mm1,mm2,s_yy,s_yyyy,rdbTheongay.Checked,s_IDmuc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;	
					case "STHCN": //Bao cao Tong hop cong no.
						ds_Data=accMyform.f_Tonghopcongno(a,s_IDchuong,s_IDtk,s_IDlk,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,s_IDdoituong,s_IDmuc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					case "STDTU": //Bao cao So theo doi tam ung.
						ds_Data=accMyform.f_Sotheodoitamung(a,s_IDchuong,s_IDtk,s_IDlk,s_IDhoatdong,s_IDkhoaphong,s_IDdoituong,s_IDnhombc,s_Tungay,s_Denngay,s_mm,s_yy,s_yyyy,rdbTheongay.Checked,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					case "SCTKT": //Bao cao So theo doi tam ung.
						ds_Data=accMyform.f_Soctcackhoanthu(a,s_IDchuong,s_IDdoituong,s_IDmuc,s_IDlk,s_sotk,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,mm1.ToString().PadLeft(2,'0'),s_yy,s_yyyy,rdbTheongay.Checked,i_DKgroup);
						accMyform.Dispose();
						break;
					case "SoNhatKyThuTien":
						ds_Data = accMyform1.get_SoNhatKyThuTien(a,txtsotaikhoan.Text,s_mm1_,s_mm2_,s_yy_);
						accMyform1.Dispose();
						break;
					case "SoNhatKyChiTien":
						ds_Data = accMyform1.get_SoNhatKyChiTien(a,txtsotaikhoan.Text,s_mm1_,s_mm2_,s_yy_);
						accMyform1.Dispose();
						break;
					case "SoNhatKyMuaHang":
						ds_Data = accMyform1.get_SoNhatKyMuaHang(a,txtsotaikhoan.Text,s_mm1_,s_mm2_,s_yy_);
						accMyform1.Dispose();
						break;
					case "SoNhatKyBanHang":
						ds_Data = accMyform1.get_SoNhatKyBanHang(a,txtsotaikhoan.Text,s_mm1_,s_mm2_,s_yy_);
						accMyform1.Dispose();
						break;
					case "SoChiTietS31" :
						int i_Tinhchat1=0;
						try {i_Tinhchat1=int.Parse(a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["tinhchat"].ToString().Trim());}
						catch{}
						ds_Data = accMyform1.get_SoChiTietS31(a,s_mm1_,s_mm2_,s_yy_,stk,s_IDloaidoituong,s_IDdoituong,s_IDkhoanmuc,i_Tinhchat1);
						accMyform1.Dispose();
						break;
					case "SoChiTietS34" :
						int i_Tinhchat2=0;
						try {i_Tinhchat2=int.Parse(a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["tinhchat"].ToString().Trim());}
						catch{}
						ds_Data = accMyform1.get_SoChiTietS31(a,s_mm1_,s_mm2_,s_yy_,stk,s_IDloaidoituong,s_IDdoituong,s_IDkhoanmuc,i_Tinhchat2);
						accMyform1.Dispose();
						break;
					case "SoChiTietS35":
						ds_Data = accMyform1.get_SoChiTietBanHang(a,txtsotaikhoan.Text,s_mm1_,s_mm2_,s_yy_);//,s_IDloaidoituong,s_IDdoituong,s_IDkhoanmuc);
						accMyform1.Dispose();
						break;
					case "SoChiPhiSanXuatKD":
						ds_Data = accMyform1.get_SoChiPhiSXKD(a,txtsotaikhoan.Text,s_mm1_,s_mm2_,s_yy_);//,s_IDloaidoituong,s_IDdoituong,s_IDkhoanmuc);
						accMyform1.Dispose();
						break;
					case "TongHopTaiKhoanTienGui":
						ds_Data = accMyform1.get_TongHopTaiKhoanTienGui(a,txtsotaikhoan.Text,s_mm1_,s_mm2_,s_yy_);//,s_IDloaidoituong,s_IDdoituong,s_IDkhoanmuc);
						accMyform1.Dispose();
						break;
					case "SoTongHopChiPhi":
						ds_Data = accMyform1.get_SoTongHopChiPhi(a,txtsotaikhoan.Text,s_IDkhoanmuc,s_mm1_,s_mm2_,s_yy_);//,s_IDloaidoituong,s_IDdoituong,s_IDkhoanmuc);
						accMyform1.Dispose();
						break;
					case "SoChiTietChiPhi":
						ds_Data = accMyform1.get_SoChiTietChiPhi(a,txtsotaikhoan.Text,s_IDkhoanmuc,s_mm1_,s_mm2_,s_yy_);//,s_IDloaidoituong,s_IDdoituong,s_IDkhoanmuc);
						accMyform1.Dispose();
						break;
					case "BKCTGCL": //Bao cao Bang ke chung tu goc cung loai (S01B). 
						int i_loaibc=-1;
						if(s_IDnhombc!="")
							i_loaibc=int.Parse(s_IDnhombc);
						ds_Data=accMyform.f_Tonghopchungtugoccungloai(a,i_loaibc,s_IDchuong,s_IDtk,s_IDlk,s_IDhoatdong,s_IDnhombc,s_Tungay,s_Denngay,s_yy,rdbTheongay.Checked,s_IDdoituong,s_IDmuc,s_IDkhoanmuc,s_IDkhoanmuc2,s_IDkhoanmuc3,s_IDkhoanmuc4,i_DKgroup);
						accMyform.Dispose();
						break;
					default:
						ds_Data.Clear();
						ds_Data.Dispose();
						break;
				}
				//Ghi DataSet ra file xml de lay cau truc lam report.
				//ds_Data.WriteXml("..\\..\\xml_data\\KT_Soquytienmat.xml",XmlWriteMode.WriteSchema);

				try
				{
					if (ds_Data==null || ds_Data.Tables[0].Rows.Count==0) MessageBox.Show("Không có số liệu !","Thông báo !");
					else
					{
						string s_fTinhchat_tk="0";
						string s_fNgaythang="",s_fGiatri11="",s_fGiatri12="",s_fGiatri21="",s_fGiatri22="";
						string s_fGiatri31="",s_fGiatri32="",s_fGiatri41="",s_fGiatri42="",s_fGiatri51="",s_fGiatri52="";
						f_Loadformula(s_Tungay,s_Denngay,mm1,mm2,yy,ref s_fTinhchat_tk,ref s_fNgaythang,ref s_fGiatri11,
							ref s_fGiatri12,ref s_fGiatri21,ref s_fGiatri22,ref s_fGiatri31,ref s_fGiatri32,
							ref s_fGiatri41,ref s_fGiatri42,ref s_fGiatri51,ref s_fGiatri52);
						
						switch (i_Loai) //i_Loai: 1 - xuat ra man hinh; 2 - xuat sang excel ; 3 - xuat ra may in. 
						{
							case 1:
                                if (s_Tenform == "SOCAI_S3b" || s_Tenform == "SCTH" || s_Tenform == "SOHANGMUCKINHPHI")
								{
									string title_Ngaythang="";
									string title_Taikhoan="",title_Sotk="",title_Loai="",title_Khoan="",title_Tinhchat="";

									if (rdbTheongay.Checked)
									{
										if (s_Tungay==s_Denngay) title_Ngaythang="Ngày "+s_Tungay;
										else title_Ngaythang="Từ ngày "+s_Tungay+" đến ngày "+s_Denngay;
									}
									else
									{
										if (mm1==mm2) title_Ngaythang="Tháng "+mm1+" năm "+yy;
										else title_Ngaythang="Từ tháng "+mm1+" đến tháng "+mm2+" năm "+yy;
									}
									if (txtloaikhoan.Text!="") 
									{
										title_Loai=txtloaikhoan.Text.Trim().Split('-')[0].ToString();
										title_Khoan=txtloaikhoan.Text.Trim().Split('-')[1].ToString();
									}
									title_Taikhoan="Tài khoản : "+txtsotaikhoan.Text+" "+txttentaikhoan.Text;
									title_Sotk=txtsotaikhoan.Text;

									string sql_tc="select b.ten as tinhchat";
									sql_tc+=" from a_dmtk a, a_dmtctk b";
									sql_tc+=" where a.tinhchat = b.id";
									sql_tc+=" and a.stk like '"+s_sotk+"'";		
									title_Tinhchat=a.get_data(sql_tc).Tables[0].Rows[0][0].ToString();
									//ds_Data=a.get_data(sql_tc);

									frmReport f=new frmReport(a,ds_Data,title_Ngaythang,title_Taikhoan,title_Sotk,title_Tinhchat,title_Loai,title_Khoan,s_Report.ToString());
									f.ShowDialog();
								}
								else if(s_Tenform=="SCTTK_M2")
								{
									string title_Tinhchat="";
									string sql_tc="select b.ten as tinhchat";
									sql_tc+=" from a_dmtk a, a_dmtctk b";
									sql_tc+=" where a.tinhchat = b.id";
									sql_tc+=" and a.stk like '"+s_sotk+"'";		
									title_Tinhchat=a.get_data(sql_tc).Tables[0].Rows[0][0].ToString();

									string s_tieude="";
									if(txtsotaikhoan.Text!="")			
										s_tieude= "Tài khoản: "+txtsotaikhoan.Text+" "+txttentaikhoan.Text;
									string s_ngaythang="";
									if (rdbTheongay.Checked)
									{
										if (s_Tungay==s_Denngay) s_ngaythang="Ngày "+s_Tungay;
										else s_ngaythang="Từ ngày "+s_Tungay+" đến ngày "+s_Denngay;
									}
									else
									{
										if (mm1==mm2) s_ngaythang="Tháng "+mm1+" năm "+yy;
										else s_ngaythang="Từ tháng "+mm1+" đến tháng "+mm2+" năm "+yy;
									}
									frmReport f=new frmReport(a,ds_Data,s_ngaythang,s_tieude, title_Tinhchat,s_Report.ToString());
									f.ShowDialog();
								}
								else if (s_Tenform=="SoNhatKyThuTien" || s_Tenform=="SoNhatKyChiTien" || s_Tenform=="SoNhatKyMuaHang" ||s_Tenform=="SoNhatKyBanHang" ||s_Tenform=="SoChiTietS35"  || s_Tenform=="SoChiTietS31" || s_Tenform=="SoChiTietS34" || s_Tenform=="SoChiPhiSanXuatKD" || s_Tenform=="TongHopTaiKhoanTienGui" || s_Tenform=="SoTongHopChiPhi" || s_Tenform=="SoChiTietChiPhi")  
								{
									stk = txtsotaikhoan.Text;
									ttk = txttentaikhoan.Text;	
									doituong = txttenloaidt.Text;
									khoanmuc = txttenkhoanmuc1.Text;
									string title_Tinhchat="";
									string sql_tc="select b.ten as tinhchat";
									sql_tc+=" from a_dmtk a, a_dmtctk b";
									sql_tc+=" where a.tinhchat = b.id";
									sql_tc+=" and a.stk like '"+s_sotk+"'";	
									title_Tinhchat=a.get_data(sql_tc).Tables[0].Rows[0][0].ToString();
									frmReport f=new frmReport(a,ds_Data,s_Report,stk,ttk,ngaythangnam,ngayin,title_Tinhchat,doituong,khoanmuc,text3);
									f.ShowDialog();		
								}
								else if(s_Tenform=="BKCTGCL")
								{
									if(s_IDnhombc=="19")
									{
										s_Report="KT_Bangtonghopchungtu_Vienphi.rpt";
									}
									else
										if(s_IDnhombc=="21")
										s_Report="KT_Bangtonghopchungtu_Kinhphi.rpt";
									frmReport_kt f=new frmReport_kt(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString());
									f.ShowDialog();
								}
								else
								{
									frmReport_kt f=new frmReport_kt(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString());
									f.ShowDialog();
								}
								break;
							case 2:
								string s_ExcelError=exportExcel.expExcel(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString());
								if (s_ExcelError!="")
									MessageBox.Show(s_ExcelError,"Thông báo!");
								break;
								//							case 3:
								//								string s_InError=Print.Printer(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString(),s_Pagesize,i_Kieuin,i_Banin); //Kieu - ngang hoac doc ; Copy - so ban in.
								//								if (s_InError=="")
								//									MessageBox.Show("Đã in xong báo cáo","Thông báo!");
								//								else MessageBox.Show(s_InError,"Lỗi in báo cáo!");
								//								break;
							default:
								frmReport_kt frm=new frmReport_kt(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString());
								frm.ShowDialog();
								break;
						}
					}
				}
				catch
				{
					MessageBox.Show("Không có số liệu !","Thông báo !");
				}
			}
		}

		private void f_Loadformula(string s_Tungay,string s_Denngay,int mm1,int mm2,int yy,
			ref string s_fTinhchat_tk,ref string s_fNgaythang,ref string s_fGiatri11,
			ref string s_fGiatri12,ref string s_fGiatri21,ref string s_fGiatri22,ref string s_fGiatri31,
			ref string s_fGiatri32,ref string s_fGiatri41,ref string s_fGiatri42,ref string s_fGiatri51,ref string s_fGiatri52)
		{
			string s_Stknghang="";
			try {s_fTinhchat_tk=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["tinhchat"].ToString().Trim();}
			catch{}
						
			if (rdbTheongay.Checked)
			{
				if (s_Tungay==s_Denngay) s_fNgaythang="Ngày "+s_Tungay;
				else s_fNgaythang="Từ ngày "+s_Tungay+" đến ngày "+s_Denngay;
			}
			else
			{
				if (mm1==mm2) s_fNgaythang="Tháng "+mm1+" năm "+yy;
				else s_fNgaythang="Từ tháng "+mm1+" đến tháng "+mm2+" năm "+yy;
			}
			s_fGiatri11=txtsotaikhoan.Text.Trim();
			s_fGiatri12=txttentaikhoan.Text.Trim();
						
			switch (s_Tenform)
			{
				case "BTHCT": 
					if (txtloaikhoan.Text.Trim()!="") 
					{
						s_fGiatri21=txtloaikhoan.Text.Trim().Split('-')[0].ToString();
						s_fGiatri22=txtloaikhoan.Text.Trim().Split('-')[1].ToString();
					}
					break;
				case "TGNHCT": 
					if (txtloaikhoan.Text.Trim()!="") 
					{
						s_fGiatri21=txtloaikhoan.Text.Trim().Split('-')[0].ToString();
						s_fGiatri22=txtloaikhoan.Text.Trim().Split('-')[1].ToString();
					}
					s_Stknghang=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
					try
					{
						System.Data.DataRow drNganhang=a.get_Nganhang(s_Stknghang);
						if (drNganhang!=null)
						{
							s_fGiatri31=drNganhang["TENNH"].ToString();
							s_fGiatri32=drNganhang["ACCOUNT"].ToString();
						}
					}
					catch{};
					break;
				case "TGNHTH": 
					if (txtloaikhoan.Text.Trim()!="") 
					{
						s_fGiatri21=txtloaikhoan.Text.Trim().Split('-')[0].ToString();
						s_fGiatri22=txtloaikhoan.Text.Trim().Split('-')[1].ToString();
					}
					s_Stknghang=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
					try
					{
						System.Data.DataRow drNganhang=a.get_Nganhang(s_Stknghang);
						if (drNganhang!=null)
						{
							s_fGiatri31=drNganhang["TENNH"].ToString();
							s_fGiatri32=drNganhang["ACCOUNT"].ToString();
						}
					}
					catch{};
					break;
				case "SDKCTGS": 
					if (txtsotaikhoan.Text!="") s_fTieude_chinh="SỔ ĐĂNG KÝ CHỨNG TỪ GHI SỔ "+txttentaikhoan.Text.Trim().ToUpper();
					else s_fTieude_chinh="SỔ ĐĂNG KÝ CHỨNG TỪ GHI SỔ";
					break;
				case "SCTGS": 
					if (txtsotaikhoan.Text!="") s_fTieude_chinh="CHỨNG TỪ GHI SỔ "+txttentaikhoan.Text.Trim().ToUpper();
					else s_fTieude_chinh="CHỨNG TỪ GHI SỔ";
					break;
				case "SCMUC": 
					if (txtloaikhoan.Text.Trim()!="") 
					{
						s_fGiatri21=txtloaikhoan.Text.Trim().Split('-')[0].ToString();
						s_fGiatri22=txtloaikhoan.Text.Trim().Split('-')[1].ToString();
					}
					s_fGiatri31="12324";//s_Nguonns;  //Nhan dang sua den day.
					s_fGiatri41=mm2.ToString().PadLeft(2,'0');
					break;
				case "SCTTK":
					if(txttendoituong.Text!="")s_fGiatri31="Tên đối tượng: "+txttendoituong.Text;
					break;
				case "SCTKT":
					if(txtsotaikhoan.Text!="")
						s_fGiatri11=txttentaikhoan.Text;					
					break;
				default: 
					break;
			}
		}
		private void f_LoadKhoaphong()
		{
			cbochon.DisplayMember="TENKP";
			cbochon.ValueMember="MAKP";

			dt_Khoaphong=a.get_DMKhoaphong().Tables[0];
			cbochon.DataSource=dt_Khoaphong;
		}
		private void f_LoadHoatdong()
		{
			listhoatdong.DisplayMember="TEN";
			listhoatdong.TextMember="MA";
			listhoatdong.ValueMember="TEN";

			dt_Dmhoatdong=a.get_DMHoatdong("").Tables[0];
			listhoatdong.DataSource=dt_Dmhoatdong;
		}
		private void f_LoadKhoanmuc(ref LibList.List listKmuc,ref System.Data.DataTable dt_Dmkmuc,string s_IDLoaikhoanmuc)
		{
			listKmuc.DisplayMember="TEN";
			listKmuc.TextMember="MA";
			listKmuc.ValueMember="TEN";

			dt_Dmkmuc=a.get_DMkhoanmuc(s_IDLoaikhoanmuc).Tables[0];
			listKmuc.DataSource=dt_Dmkmuc;
		}
		private void f_LoadTaikhoan(System.Data.DataTable dt_Taikhoan)
		{
			listtaikhoan.DisplayMember="TTK";
			listtaikhoan.TextMember="STK";
			listtaikhoan.ValueMember="TTK";
			listtaikhoan.DataSource=dt_Taikhoan;
		}
		//Rieng doi voi bao cao so tong hop chung tu
		private void f_LoadCbo_Baocaotheo()
		{
			cbochon.Items.Clear();
			cbochon.Items.Add("Tất cả");
			cbochon.Items.Add("Tài khoản nợ");
			cbochon.Items.Add("Tài khoản có");
			cbochon.SelectedIndex=0;
		}
		private void f_LoadLoaiDoituong()
		{
			listloaidt.DisplayMember="ten";
			listloaidt.TextMember="id";
			listloaidt.ValueMember="ten";

			dt_Dmloaidt=a.get_DMloaidt().Tables[0];
			listloaidt.DataSource=dt_Dmloaidt;
		}
		private void f_LoadDoituong(string s_IDloaidt)
		{
			listdoituong.DisplayMember="TENDT";
			listdoituong.TextMember="MADT";
			listdoituong.ValueMember="TENDT";

			dt_Dmdoituong=a.get_DMDoituong(s_IDloaidt).Tables[0];
			listdoituong.DataSource=dt_Dmdoituong;
		}
		private void f_LoadChuong()
		{
			listchuong.DisplayMember="TEN";
			listchuong.TextMember="MA";
			listchuong.ValueMember="TEN";

			dt_Dmchuong=a.get_DMChuong().Tables[0];
			listchuong.DataSource=dt_Dmchuong;
		}
		private void f_LoadMuc(DataTable dtm)
		{
			listmuc.DisplayMember="TTK";
			listmuc.TextMember="MTM";
			listmuc.ValueMember="TTK";
			
			listmuc.DataSource=dtm;
		}
		private void f_LoadNhombc()
		{
			listnhombc.DisplayMember="TEN";
			listnhombc.ValueMember="TEN";
			listnhombc.TextMember="MA";

			dt_Dmnhombc=a.get_DMNhombc().Tables[0];
			listnhombc.DataSource=dt_Dmnhombc;						
		}
		private void f_LoadLoaikhoan()
		{
			listloaikhoan.DisplayMember="TLK";
			listloaikhoan.TextMember="LK";
			listloaikhoan.ValueMember="TLK";

			dt_Dmlk=a.get_DMLoaikhoan().Tables[0];
			listloaikhoan.DataSource=dt_Dmlk;
		}

		private void f_LoadLoaictu(ref LibList.List listLoaictu,ref System.Data.DataTable dt_Dmloaictu,string s_IDchucnang)
		{
			listLoaictu.DisplayMember="TEN";
			listLoaictu.TextMember="MASO";
			listLoaictu.ValueMember="TEN";

			dt_Dmloaictu=a.get_DMloaictu(s_IDchucnang).Tables[0];
			listLoaictu.DataSource=dt_Dmloaictu;
		}
		#endregion dong cac ham khoi tao

		private void f_Loadform_FORMCHUNG(string s_Tieudeform,string s_Filereport,string s_Tieudereport,string s_Giay,int i_In,int i_Soto)
		{
			this.Text=s_Tieudeform;			
			s_Report=s_Filereport;
			i_Kieuin=i_In; i_Banin=i_Soto; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize=s_Giay;
			s_fTieude_chinh=s_Tieudereport;
			f_Dispose_Control(false);
		}

		private void f_Dispose_Control(bool b_All)
		{
			try
			{
				if (b_All)			
				{ 
					grbchon.Dispose(); grbNgay.Dispose(); grbThang.Dispose(); grpNen.Dispose(); 
					lblTungay.Dispose(); dtpTungay.Dispose(); lblDenngay.Dispose(); dtpDenngay.Dispose();
					lblTuthang.Dispose(); numTuthang.Dispose(); lblDenthang.Dispose(); numDenthang.Dispose(); lblNam.Dispose(); numNam.Dispose();
					butXem.Dispose(); butExcel.Dispose(); butIn.Dispose(); 
				}
				else lblError.Dispose(); 

				if (!lblchuong.Visible || b_All)			
				{ lblchuong.Dispose(); txtchuong.Dispose(); txttenchuong.Dispose(); listchuong.Dispose();}

				if (!lbltaikhoan.Visible || b_All)		
				{ lbltaikhoan.Dispose(); txtsotaikhoan.Dispose(); txttentaikhoan.Dispose(); listtaikhoan.Dispose();}

				if (!lblloaikhoan.Visible || b_All)		
				{ lblloaikhoan.Dispose(); txtloaikhoan.Dispose(); txttenloaikhoan.Dispose(); listloaikhoan.Dispose();}

				if (!lblmuc.Visible || b_All)			
				{ lblmuc.Dispose(); txtmuc.Dispose(); txttenmuc.Dispose(); listmuc.Dispose();}
				
				if (!lblkhoanmuc1.Visible || b_All)			
				{ lblkhoanmuc1.Dispose(); txtkhoanmuc1.Dispose(); txttenkhoanmuc1.Dispose(); listkhoanmuc1.Dispose();}

				if (!lblkhoanmuc2.Visible || b_All)			
				{ lblkhoanmuc2.Dispose(); txtkhoanmuc2.Dispose(); txttenkhoanmuc2.Dispose(); listkhoanmuc2.Dispose();}

				if (!lblkhoanmuc3.Visible || b_All)			
				{ lblkhoanmuc3.Dispose(); txtkhoanmuc3.Dispose(); txttenkhoanmuc3.Dispose(); listkhoanmuc3.Dispose();}

				if (!lblkhoanmuc4.Visible || b_All)			
				{ lblkhoanmuc4.Dispose(); txtkhoanmuc4.Dispose(); txttenkhoanmuc4.Dispose(); listkhoanmuc4.Dispose();}

				if (!lblhoatdong.Visible || b_All)		
				{ lblhoatdong.Dispose(); txthoatdong.Dispose(); txttenhoatdong.Dispose(); listhoatdong.Dispose();}
				
				if (!lblnhombc.Visible || b_All)		
				{ lblnhombc.Dispose(); txtnhombc.Dispose(); txtnhombc.Dispose(); listnhombc.Dispose();}
				
				if (!lbldoituong.Visible || b_All)		
				{ lbldoituong.Dispose(); txtdoituong.Dispose(); txttendoituong.Dispose(); listdoituong.Dispose();}
				

				if (!lblbctheo.Visible || b_All)			
				{ lblbctheo.Dispose(); cbobctheo.Dispose();}
			}
			catch{}	;

		}

		
		private void frmReport_yc_Load(object sender, System.EventArgs e)
		{
			try
			{
				//an cbochon (dung cho form b/c so tong hop chung tu)
				cbochon.Visible=false;
				//Gan gia tri khoi tao cho cac o thang nam
				numTuthang.Value=DateTime.Now.Month;
				numDenthang.Value=DateTime.Now.Month;
				numNam.Value=DateTime.Now.Year;
				numNam.Value=DateTime.Now.Year;
				f_Loaddm();		
				f_Loadform();
				dtpTungay.Focus();
			}
			catch{};
		{}
		}

		private void txtnhombc_TextChanged(object sender, System.EventArgs e)
		{			
			if (this.ActiveControl==txtnhombc && dt_Dmnhombc!=null)
			{
				Filter_List(listnhombc,txtnhombc.Text.Trim(),"ma","TEN");
				switch (s_Tenform)
				{
					case "BTHCT": 						
						listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtnhombc.Location.X+8,158,txtnhombc.Width+txttennhombc.Width+2,txtnhombc.Height,100);
						break;
					case "BKCTGCL": 						
						listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtnhombc.Location.X+8,114,txtnhombc.Width+txttennhombc.Width+2,txtnhombc.Height,100);
						break;
					case "XXXX": 
						listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtnhombc.Location.X+8,158,txtnhombc.Width+txttennhombc.Width+2,txtnhombc.Height,100);
						break;
					default:
						listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtnhombc.Location.X+8,158,txtnhombc.Width+txttennhombc.Width+2,txtnhombc.Height,100);
						break;
				}
			}	
		}

		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void butXem_Click(object sender, System.EventArgs e)
		{
			Display(1);
		}

		private void txtdoituong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtdoituong && dt_Dmdoituong!=null)
			{
				Filter_List(listdoituong,txtdoituong.Text.Trim(),"madt","tendt");
				switch (s_Tenform)
				{
					case "STDTU": 
						listdoituong.BrowseToDmtk(txtdoituong,txttendoituong,txtnhombc,txtdoituong.Location.X+8,138,txtdoituong.Width+0+txttendoituong.Width,txtdoituong.Height,100);
						break;
					case "SCTTK": 
						listdoituong.BrowseToDmtk(txtdoituong,txttendoituong,txtnhombc,txtdoituong.Location.X+8,138,txtdoituong.Width+0+txttendoituong.Width,txtdoituong.Height,100);
						break;
					default:
						listdoituong.BrowseToDmtk(txtdoituong,txttendoituong,txtnhombc,txtdoituong.Location.X+8,138,txtdoituong.Width+0+txttendoituong.Width,txtdoituong.Height,100);
						break;
				}
			}	
		}

		private void txtchuong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtchuong && dt_Dmchuong!=null)
			{
				Filter_List(listchuong,txtchuong.Text.Trim(),"ma","ten");
				listchuong.BrowseToDmtk(txtchuong,txttenchuong,txthoatdong,txtchuong.Location.X+8,186,txtchuong.Width+0+txttenchuong.Width,txtchuong.Height,100);
			}	
		}

		private void txtchuong_Validated(object sender, System.EventArgs e)
		{
			txttenchuong.Text="";
			if (txtchuong.Text!="")
			{
				r=a.getrowbyid(dt_Dmchuong,"ma='"+txtchuong.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenchuong.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}	

		private void txtchuong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmchuong!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listchuong.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listchuong.Visible) 
					{
						listchuong.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtchuong_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmchuong!=null)
			{
				listchuong.Focus();
				Filter_List(listchuong,txtchuong.Text.Trim(),"ma","ten");
				listchuong.BrowseToDmtk(txtchuong,txttenchuong,txthoatdong,txtchuong.Location.X+8,186,txtchuong.Width+0+txttenchuong.Width,txtchuong.Height,100);
			}
		}

		private void txtdoituong_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmdoituong!=null)
			{
				listdoituong.Focus();
				Filter_List(listdoituong,txtdoituong.Text.Trim(),"madt","tendt");
				switch (s_Tenform)
				{
					case "STDTU": 
						listdoituong.BrowseToDmtk(txtdoituong,txttendoituong,txtnhombc,txtdoituong.Location.X+8,138,txtdoituong.Width+0+txttendoituong.Width,txtdoituong.Height,100);
						break;
					case "SCTTK": 
						listdoituong.BrowseToDmtk(txtdoituong,txttendoituong,txtnhombc,txtdoituong.Location.X+8,138,txtdoituong.Width+0+txttendoituong.Width,txtdoituong.Height,100);
						break;
					default:
						listdoituong.BrowseToDmtk(txtdoituong,txttendoituong,txtnhombc,txtdoituong.Location.X+8,138,txtdoituong.Width+0+txttendoituong.Width,txtdoituong.Height,100);
						break;
				}
			}
		}

		private void txtdoituong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmdoituong!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listdoituong.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listdoituong.Visible) 
					{
						listdoituong.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtdoituong_Validated(object sender, System.EventArgs e)
		{
			txttendoituong.Text="";
			if (txtdoituong.Text!="")
			{
				r=a.getrowbyid(dt_Dmdoituong,"madt='"+txtdoituong.Text.Trim()+"'");
				if (r!=null) 
				{
					txttendoituong.Text=r["tendt"].ToString();
				}
			}
			hide_List();
		}

		private void txthoatdong_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmhoatdong!=null)
			{
				listhoatdong.Focus();
				Filter_List(listhoatdong,txthoatdong.Text.Trim(),"ma","ten");
				switch (s_Tenform)
				{
					case "BTHCT": 
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
					case "STDTU": 
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
					case "SCTTK": 
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
					default:
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
				}
			}
		}

		private void txthoatdong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmhoatdong!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listhoatdong.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listhoatdong.Visible) 
					{
						listhoatdong.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			//else SendKeys.Send("{Tab}");
		}

		private void txthoatdong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txthoatdong && dt_Dmhoatdong!=null)
			{
				Filter_List(listhoatdong,txthoatdong.Text.Trim(),"ma","ten");
				switch (s_Tenform)
				{
					case "BTHCT": 
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
					case "STDTU": 
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
					case "SCTTK": 
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
					default:
						listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtloaikhoan,txthoatdong.Location.X+8,206,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height,100);
						break;
				}
			}	
		}

		private void txthoatdong_Validated(object sender, System.EventArgs e)
		{
			txttenhoatdong.Text="";
			if (txthoatdong.Text!="")
			{
				r=a.getrowbyid(dt_Dmhoatdong,"ma='"+txthoatdong.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenhoatdong.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}

		private void txtmuc_DoubleClick(object sender, System.EventArgs e)
		{			
			if (dt_Dmmuc!=null && b_Muc)
			{
				listmuc.Focus();
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listmuc,txtmuc.Text.Trim(),"maso","ten");
						listmuc.BrowseToDmtk(txtmuc,txttenmuc,txtkhoanmuc1,txtkhoanmuc1.Location.X+8,254,txtmuc.Width+0+txttenmuc.Width,txtmuc.Height,100);
						break;
					case "SCTGS":
						Filter_List(listmuc,txtmuc.Text.Trim(),"maso","ten");
						listmuc.BrowseToDmtk(txtmuc,txttenmuc,txtkhoanmuc1,txtkhoanmuc1.Location.X+8,254,txtmuc.Width+0+txttenmuc.Width,txtmuc.Height,100);
						break;
					default:
						Filter_List(listmuc,txtmuc.Text.Trim(),"mtm","");
						listmuc.BrowseToDmtk(txtmuc,txttenmuc,txtkhoanmuc1,txtkhoanmuc1.Location.X+8,254,txtmuc.Width+0+txttenmuc.Width,txtmuc.Height,100);
						break;
				}
			}

		}

		private void txtmuc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmmuc!=null && b_Muc)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listmuc.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listmuc.Visible) 
					{
						listmuc.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtmuc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtmuc && dt_Dmmuc!=null && b_Muc)
			{
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listmuc,txtmuc.Text.Trim(),"maso","ten");
						listmuc.BrowseToDmtk(txtmuc,txttenmuc,txtkhoanmuc1,txtmuc.Location.X+8,254,txtmuc.Width+0+txttenmuc.Width,txtmuc.Height,100);
						break;
					case "SCTGS":
						Filter_List(listmuc,txtmuc.Text.Trim(),"maso","ten");
						listmuc.BrowseToDmtk(txtmuc,txttenmuc,txtkhoanmuc1,txtmuc.Location.X+8,254,txtmuc.Width+0+txttenmuc.Width,txtmuc.Height,100);
						break;
					default:
						Filter_List(listmuc,txtmuc.Text.Trim(),"mtm","");
						listmuc.BrowseToDmtk(txtmuc,txttenmuc,txtkhoanmuc1,txtmuc.Location.X+8,254,txtmuc.Width+0+txttenmuc.Width,txtmuc.Height,100);
						break;
				}
			}	
		}

		private void txtmuc_Validated(object sender, System.EventArgs e)
		{
			txttenmuc.Text="";
			if (txtmuc.Text!="" && b_Muc)
			{
				switch (s_Tenform)
				{
					case "SDKCTGS":
						r=a.getrowbyid(dt_Dmmuc,"maso='"+txtmuc.Text.Trim()+"'");
						if (r!=null) 
						{
							txttenmuc.Text=r["ten"].ToString();
						}
						break;
					case "SCTGS":
						r=a.getrowbyid(dt_Dmmuc,"maso='"+txtmuc.Text.Trim()+"'");
						if (r!=null) 
						{
							txttenmuc.Text=r["ten"].ToString();
						}
						break;
					default:
						r=a.getrowbyid(dt_Dmmuc,"mtm='"+txtmuc.Text.Trim()+"'");
						if (r!=null) 
						{
							txttenmuc.Text=r["ttk"].ToString();
						}
						break;
				}
			}
			hide_List();
		}

		private void txtloaikhoan_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtloaikhoan && dt_Dmlk!=null)
			{
				Filter_List(listloaikhoan,txtloaikhoan.Text.Trim(),"lk","");
				listloaikhoan.BrowseToDmtk(txtloaikhoan,txttenloaikhoan,txtmuc,txtloaikhoan.Location.X+8,230,txtloaikhoan.Width+0+txttenloaikhoan.Width,txtloaikhoan.Height,100);				
			}	
		}

		private void txtloaikhoan_DoubleClick(object sender, System.EventArgs e)
		{
			
			if (dt_Dmlk!=null)
			{
				listloaikhoan.Focus();
				Filter_List(listloaikhoan,txtloaikhoan.Text.Trim(),"lk","");
				listloaikhoan.BrowseToDmtk(txtloaikhoan,txttenloaikhoan,txtmuc,txtloaikhoan.Location.X+8,230,txtloaikhoan.Width+0+txttenloaikhoan.Width,txtloaikhoan.Height,100);
			}
		}

		private void txtloaikhoan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmlk!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listloaikhoan.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listloaikhoan.Visible) 
					{
						listloaikhoan.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtloaikhoan_Validated(object sender, System.EventArgs e)
		{
			txttenloaikhoan.Text="";
			if (txtloaikhoan.Text!="")
			{
				r=a.getrowbyid(dt_Dmlk,"lk='"+txtloaikhoan.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenloaikhoan.Text=r["tlk"].ToString();
				}
			}
			hide_List();
		}

		private void txtkhoanmuc1_TextChanged(object sender, System.EventArgs e)
		{			
			try
			{
				if (this.ActiveControl==txtkhoanmuc1 && dt_Dmkhoanmuc1!=null && b_Khoanmuc)
				{				
					Filter_List(listkhoanmuc1,txtkhoanmuc1.Text.Trim(),"ma","ten");
					listkhoanmuc1.BrowseToDmtk(txtkhoanmuc1,txttenkhoanmuc1,txtkhoanmuc2,txtkhoanmuc1.Location.X+8,280,txtkhoanmuc1.Width+0+txttenkhoanmuc1.Width,txtkhoanmuc1.Height,100);
				
				}	
			}
			catch{}
		}

		private void txtkhoanmuc1_DoubleClick(object sender, System.EventArgs e)
		{
			try
			{
				if (dt_Dmkhoanmuc1!=null && b_Khoanmuc)
				{
					listkhoanmuc1.Focus();		
					Filter_List(listkhoanmuc1,txtkhoanmuc1.Text.Trim(),"ma","ten");
					listkhoanmuc1.BrowseToDmtk(txtkhoanmuc1,txttenkhoanmuc1,txtkhoanmuc2,txtkhoanmuc1.Location.X+8,280,txtkhoanmuc1.Width+0+txttenkhoanmuc1.Width,txtkhoanmuc1.Height,100);
		
				}
			}
			catch{}
		}

		private void txtkhoanmuc1_Validated(object sender, System.EventArgs e)
		{
			txttenkhoanmuc1.Text="";
			try
			{
				if (txtkhoanmuc1.Text!="" && b_Khoanmuc)
				{
					switch (s_Tenform)
					{
						default:
							r=a.getrowbyid(dt_Dmkhoanmuc1,"ma='"+txtkhoanmuc1.Text.Trim()+"'");
							if (r!=null) 
							{
								txttenkhoanmuc1.Text=r["ten"].ToString();
							}
							break;
					}
				}
			}
			catch{}
			hide_List();
		}

		private void txtkhoanmuc1_Enter(object sender, System.EventArgs e)
		{

			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SQTM1" || s_Tenform=="SCMUC" || s_Tenform=="SCTH1" || s_Tenform=="TGNHCT" || 
				s_Tenform=="TGNHTH" || s_Tenform=="SCTTK" || s_Tenform=="STHCN") s_Maubaocao="SKMUC";
			string s_IDloaikm="";
			try
			{
				switch (s_Maubaocao)
				{
					case "SKMUC":
						try
						{
							if (txtsotaikhoan.Text!="")
							{
								//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
								//txtMuc.Text=""; txtTenmuc.Text="";
								s_IDloaikm=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm"].ToString().Trim();
								f_LoadKhoanmuc(ref listkhoanmuc1,ref dt_Dmkhoanmuc1,s_IDloaikm);
								b_Khoanmuc=true;
							}
							else
							{
								b_Khoanmuc=false;
								txtkhoanmuc1.Text=""; txttenkhoanmuc1.Text="";
								SendKeys.Send("{Tab}");
								//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
							}
						}
						catch{b_Khoanmuc=false;}	;
						break;
					default:
						//if (lblkhoanmuc1.Visible)
						//{
						try
						{
							if (txtsotaikhoan.Text!="")
							{
								//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
								//txtMuc.Text=""; txtTenmuc.Text="";
								s_IDloaikm=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm"].ToString().Trim();								
								f_LoadKhoanmuc(ref listkhoanmuc1,ref dt_Dmkhoanmuc1,s_IDloaikm);
								b_Khoanmuc=true;
							}
							else
							{
								b_Khoanmuc=false;
								txtkhoanmuc1.Text=""; txttenkhoanmuc1.Text="";								
								SendKeys.Send("{Tab}");
								//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
							}
						}
						catch
						{
							b_Khoanmuc=false;							
							SendKeys.Send("{Tab}");
						}
						//}
						break;
				}
			}
			catch{}
		}

		private void txtkhoanmuc1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			try
			{
				if (dt_Dmkhoanmuc1!=null && b_Khoanmuc)
				{
					if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listkhoanmuc1.Focus();
					else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
					{
						if (listkhoanmuc1.Visible) 
						{
							listkhoanmuc1.Focus();
							SendKeys.Send("{Down}");
						}
						else SendKeys.Send("{Tab}");
					}
				}
				else SendKeys.Send("{Tab}");
			}
			catch{}
		}
		private void txtkhoanmuc2_DoubleClick(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SDKCTGS" || s_Tenform=="SCTGS") s_Maubaocao="SCTGS";
			if (s_Tenform=="SQTM1" || s_Tenform=="SCMUC" || s_Tenform=="SCTH1" || s_Tenform=="TGNHCT" ||
				s_Tenform=="TGNHTH" || s_Tenform=="SCTTK" || s_Tenform=="STHCN") s_Maubaocao="SKMUC";

			if (dt_Dmkhoanmuc2!=null && b_Khoanmuc2)
			{
				listkhoanmuc2.Focus();
				switch (s_Maubaocao)
				{
					case "SKMUC":
						Filter_List(listkhoanmuc2,txtkhoanmuc2.Text.Trim(),"ma","ten");
						listkhoanmuc2.BrowseToDmtk(txtkhoanmuc2,txttenkhoanmuc2,txtkhoanmuc3,txtkhoanmuc2.Location.X+8,302,txtkhoanmuc2.Width+0+txttenkhoanmuc2.Width,txtkhoanmuc2.Height,100);
						break;
					default:
						Filter_List(listkhoanmuc2,txtkhoanmuc2.Text.Trim(),"ma","ten");
						listkhoanmuc2.BrowseToDmtk(txtkhoanmuc2,txttenkhoanmuc2,txtkhoanmuc3,txtkhoanmuc2.Location.X+8,302,txtkhoanmuc2.Width+0+txttenkhoanmuc2.Width,txtkhoanmuc2.Height,100);
						break;
				}
			}
		}

		private void txtkhoanmuc2_Enter(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SQTM1" || s_Tenform=="SCMUC" || s_Tenform=="SCTH1" || s_Tenform=="TGNHCT" || 
				s_Tenform=="TGNHTH" || s_Tenform=="SCTTK" || s_Tenform=="STHCN") s_Maubaocao="SKMUC";
			string s_IDloaikm2="";

			switch (s_Maubaocao)
			{
				case "SKMUC":
					try
					{
						if (txtsotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							s_IDloaikm2=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm2"].ToString().Trim();
							f_LoadKhoanmuc(ref listkhoanmuc2,ref dt_Dmkhoanmuc2,s_IDloaikm2);
							b_Khoanmuc2=true;
						}
						else
						{
							b_Khoanmuc2=false;
							txtkhoanmuc2.Text=""; txttenkhoanmuc2.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch{b_Khoanmuc2=false;}	;
					break;
				default:
					//if (lblkhoanmuc1.Visible)
					//{
					try
					{
						if (txtsotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							s_IDloaikm2=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm2"].ToString().Trim();
							f_LoadKhoanmuc(ref listkhoanmuc2,ref dt_Dmkhoanmuc2,s_IDloaikm2);
							b_Khoanmuc=true;
						}
						else
						{
							b_Khoanmuc2=false;
							txtkhoanmuc2.Text=""; txttenkhoanmuc2.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch
					{
						b_Khoanmuc2=false;
						txtkhoanmuc2.Text=""; txttenkhoanmuc2.Text="";
						SendKeys.Send("{Tab}");
					}
					//}
					break;
			}
		}

		private void txtkhoanmuc2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmkhoanmuc2!=null && b_Khoanmuc2)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listkhoanmuc2.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listkhoanmuc2.Visible) 
					{
						listkhoanmuc2.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtkhoanmuc2_TextChanged(object sender, System.EventArgs e)
		{
			
			if (this.ActiveControl==txtkhoanmuc2 && dt_Dmkhoanmuc2!=null && b_Khoanmuc2)
			{			
				Filter_List(listkhoanmuc2,txtkhoanmuc2.Text.Trim(),"ma","ten");
				listkhoanmuc2.BrowseToDmtk(txtkhoanmuc2,txttenkhoanmuc2,txtkhoanmuc3,txtkhoanmuc2.Location.X+8,302,txtkhoanmuc2.Width+0+txttenkhoanmuc2.Width,txtkhoanmuc2.Height,100);			
			}	
		}

		private void txtkhoanmuc2_Validated(object sender, System.EventArgs e)
		{
			txttenkhoanmuc2.Text="";
			if (txtkhoanmuc2.Text!="" && b_Khoanmuc2)
			{
				switch (s_Tenform)
				{
					default:
						r=a.getrowbyid(dt_Dmkhoanmuc2,"ma='"+txtkhoanmuc2.Text.Trim()+"'");
						if (r!=null) 
						{
							txttenkhoanmuc2.Text=r["ten"].ToString();
						}
						break;
				}
			}
			hide_List();
		}
		private void txtkhoanmuc3_Validated(object sender, System.EventArgs e)
		{
			txttenkhoanmuc3.Text="";
			if (txtkhoanmuc3.Text!="" && b_Khoanmuc3)
			{
				switch (s_Tenform)
				{
					default:
						r=a.getrowbyid(dt_Dmkhoanmuc3,"ma='"+txtkhoanmuc3.Text.Trim()+"'");
						if (r!=null) 
						{
							txttenkhoanmuc3.Text=r["ten"].ToString();
						}
						break;
				}
			}
			hide_List();
		}

		private void txtkhoanmuc3_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmkhoanmuc3!=null && b_Khoanmuc3)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listkhoanmuc3.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listkhoanmuc3.Visible) 
					{
						listkhoanmuc3.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtkhoanmuc3_Enter(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SQTM1" || s_Tenform=="SCMUC" || s_Tenform=="SCTH1" || s_Tenform=="TGNHCT" || 
				s_Tenform=="TGNHTH" || s_Tenform=="SCTTK" || s_Tenform=="STHCN") s_Maubaocao="SKMUC";
			string s_IDloaikm3="";
			switch (s_Maubaocao)
			{
				case "SKMUC":
					try
					{
						if (txtsotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							s_IDloaikm3=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm3"].ToString().Trim();
							f_LoadKhoanmuc(ref listkhoanmuc3,ref dt_Dmkhoanmuc3,s_IDloaikm3);
							b_Khoanmuc3=true;
						}
						else
						{
							b_Khoanmuc3=false;
							txtkhoanmuc3.Text=""; txttenkhoanmuc3.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch{b_Khoanmuc3=false;}	;
					break;
				default:
					//if (lblkhoanmuc1.Visible)
					//{
					try
					{
						if (txtsotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							s_IDloaikm3=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm3"].ToString().Trim();
							f_LoadKhoanmuc(ref listkhoanmuc3,ref dt_Dmkhoanmuc3,s_IDloaikm3);
							b_Khoanmuc3=true;
						}
						else
						{
							b_Khoanmuc3=false;
							txtkhoanmuc3.Text=""; txttenkhoanmuc3.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch
					{
						b_Khoanmuc3=false;
						txtkhoanmuc3.Text=""; txttenkhoanmuc3.Text="";
						SendKeys.Send("{Tab}");
					}
					//}
					break;
			}
		}

		private void txtkhoanmuc3_DoubleClick(object sender, System.EventArgs e)
		{			
			if (dt_Dmkhoanmuc3!=null && b_Khoanmuc3)
			{
				listkhoanmuc3.Focus();		
				Filter_List(listkhoanmuc3,txtkhoanmuc3.Text.Trim(),"ma","ten");
				listkhoanmuc3.BrowseToDmtk(txtkhoanmuc3,txttenkhoanmuc3,txtkhoanmuc4,txtkhoanmuc3.Location.X+8,326,txtkhoanmuc3.Width+0+txttenkhoanmuc3.Width,txtkhoanmuc3.Height,100);
		
			}
		}

		private void txtkhoanmuc3_TextChanged(object sender, System.EventArgs e)
		{			
			if (this.ActiveControl==txtkhoanmuc3 && dt_Dmkhoanmuc3!=null && b_Khoanmuc3)
			{		
				Filter_List(listkhoanmuc3,txtkhoanmuc3.Text.Trim(),"ma","ten");
				listkhoanmuc3.BrowseToDmtk(txtkhoanmuc3,txttenkhoanmuc3,txtkhoanmuc4,txtkhoanmuc3.Location.X+8,326,txtkhoanmuc3.Width+0+txttenkhoanmuc3.Width,txtkhoanmuc3.Height,100);
		
			}	
		}
		private void txtkhoanmuc4_Validated(object sender, System.EventArgs e)
		{
			txttenkhoanmuc4.Text="";
			if (txtkhoanmuc4.Text!="" && b_Khoanmuc4)
			{
				switch (s_Tenform)
				{
					default:
						r=a.getrowbyid(dt_Dmkhoanmuc4,"ma='"+txtkhoanmuc4.Text.Trim()+"'");
						if (r!=null) 
						{
							txttenkhoanmuc4.Text=r["ten"].ToString();
						}
						break;
				}
			}
			hide_List();
		}

		private void txtkhoanmuc4_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmkhoanmuc4!=null && b_Khoanmuc)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listkhoanmuc4.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listkhoanmuc4.Visible) 
					{
						listkhoanmuc4.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtkhoanmuc4_Enter(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SQTM1" || s_Tenform=="SCMUC" || s_Tenform=="SCTH1" || s_Tenform=="TGNHCT" || 
				s_Tenform=="TGNHTH" || s_Tenform=="SCTTK" || s_Tenform=="STHCN") s_Maubaocao="SKMUC";
			string s_IDloaikm4="";

			switch (s_Maubaocao)
			{
				case "SKMUC":
					try
					{
						if (txtsotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							s_IDloaikm4=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm4"].ToString().Trim();
							f_LoadKhoanmuc(ref listkhoanmuc4,ref dt_Dmkhoanmuc4,s_IDloaikm4);
							b_Khoanmuc4=true;
						}
						else
						{
							b_Khoanmuc4=false;
							txtkhoanmuc4.Text=""; txttenkhoanmuc4.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch{b_Khoanmuc4=false;}	;
					break;
				default:
					//if (lblkhoanmuc1.Visible)
					//{
					try
					{
						if (txtsotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							s_IDloaikm4=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text.Trim()+"'")["loaikm4"].ToString().Trim();
							f_LoadKhoanmuc(ref listkhoanmuc4,ref dt_Dmkhoanmuc4,s_IDloaikm4);
							b_Khoanmuc4=true;
						}
						else
						{
							b_Khoanmuc4=false;
							txtkhoanmuc4.Text=""; txttenkhoanmuc4.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch
					{
						b_Khoanmuc4=false;
						txtkhoanmuc4.Text=""; txttenkhoanmuc4.Text="";
						SendKeys.Send("{Tab}");
					}
					//}
					break;
			}
		}

		private void txtkhoanmuc4_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmkhoanmuc4!=null && b_Khoanmuc4)
			{
				listkhoanmuc4.Focus();
				switch (s_Tenform)
				{
					case "BTHCT":
						Filter_List(listkhoanmuc4,txtkhoanmuc4.Text.Trim(),"ma","ten");
						listkhoanmuc4.BrowseToDmtk(txtkhoanmuc4,txttenkhoanmuc4,cbochon,txtkhoanmuc4.Location.X+8,350,txtkhoanmuc4.Width+0+txttenkhoanmuc4.Width,txtkhoanmuc4.Height,100);
						break;
					default:
						Filter_List(listkhoanmuc4,txtkhoanmuc4.Text.Trim(),"ma","ten");
						listkhoanmuc4.BrowseToDmtk(txtkhoanmuc4,txttenkhoanmuc4,cbobctheo,txtkhoanmuc4.Location.X+8,350,txtkhoanmuc4.Width+0+txttenkhoanmuc4.Width,txtkhoanmuc4.Height,100);
						break;
				}
			}
		}

		private void txtkhoanmuc4_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtkhoanmuc4 && dt_Dmkhoanmuc4!=null && b_Khoanmuc4)
			{
				switch (s_Tenform)
				{
					case "BTHCT":
						Filter_List(listkhoanmuc4,txtkhoanmuc4.Text.Trim(),"ma","ten");
						listkhoanmuc4.BrowseToDmtk(txtkhoanmuc4,txttenkhoanmuc4,cbochon,txtkhoanmuc4.Location.X+8,350,txtkhoanmuc4.Width+0+txttenkhoanmuc4.Width,txtkhoanmuc4.Height,100);
						break;
					default:
						Filter_List(listkhoanmuc4,txtkhoanmuc4.Text.Trim(),"ma","ten");
						listkhoanmuc4.BrowseToDmtk(txtkhoanmuc4,txttenkhoanmuc4,cbobctheo,txtkhoanmuc4.Location.X+8,350,txtkhoanmuc4.Width+0+txttenkhoanmuc4.Width,txtkhoanmuc4.Height,100);
						break;
				}
			}	
		}
		private void txtnhombc_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmnhombc!=null)
			{
				listnhombc.Focus();
				Filter_List(listnhombc,txtnhombc.Text.Trim(),"ma","TEN");
				switch (s_Tenform)
				{
					case "BTHCT": 
						listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtnhombc.Location.X+8,158,txtnhombc.Width+txttennhombc.Width+2,txtnhombc.Height,100);
						break;
					case "XXXX": 
						listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtnhombc.Location.X+8,158,txtnhombc.Width+txttennhombc.Width+2,txtnhombc.Height,100);
						break;
					default:
						listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtnhombc.Location.X+8,158,txtnhombc.Width+txttennhombc.Width+2,txtnhombc.Height,100);
						break;
				}
			}
		}

		private void txtnhombc_Validated(object sender, System.EventArgs e)
		{
			if (txtnhombc.Text!="")
			{
				r=a.getrowbyid(dt_Dmnhombc,"ma='"+txtnhombc.Text.Trim()+"'");
				if (r!=null) 
				{
					txttennhombc.Text=r["TEN"].ToString();
				}
			}			
			hide_List();
		}		
		private void txtnhombc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmnhombc!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listnhombc.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listnhombc.Visible) 
					{
						listnhombc.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void rdbTheongay_CheckedChanged(object sender, System.EventArgs e)
		{
			grbThang.Enabled=!rdbTheongay.Checked;
			grbNgay.Enabled=rdbTheongay.Checked;	
		}

		private void rdbTheothang_CheckedChanged(object sender, System.EventArgs e)
		{
			grbThang.Enabled=rdbTheothang.Checked;
			grbNgay.Enabled=!rdbTheothang.Checked;			
		}

		private void txtsotaikhoan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmtk!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listtaikhoan.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listtaikhoan.Visible) 
					{
						listtaikhoan.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtmuc_Enter(object sender, System.EventArgs e)
		{
			try
			{
				if (txtsotaikhoan.Text!="")
				{					
					DataRow r=a.getrowbyid(dt_Dmtk,"stk='"+txtsotaikhoan.Text+"'");
					string sql="";
					if (r!=null)
					{
						if (int.Parse(r["mlns"].ToString())==1 || int.Parse(r["ctmlns"].ToString())==1)
						{
							//							sql="select a.stk,a.ttk,a.id,b.tennhom ";
							//							sql+="from a_dmch a left join a_dmnhom b on a.nhmuc=b.id ";
							//							if (int.Parse(r["ctmlns"].ToString())==1) sql+=" where a.cd in (1,2) and a.sudung=1";//a.c=1
							//							else sql+=" where a.cd=2 and a.sudung=1";//a.sp=4
							//							sql+=" order by a.cc";
							//							dt_Dmmuc=a.get_data(sql).Tables[0];
							dt_Dmmuc=a.get_DMMuc().Tables[0];
							f_LoadMuc(dt_Dmmuc);							
							b_Muc=true;
						}
					}
				}
				else
				{
					b_Muc=false;
					txtmuc.Text=""; txttenmuc.Text="";
					SendKeys.Send("{Tab}");							
				}
			}
			catch
			{
				b_Muc=false;							
				SendKeys.Send("{Tab}");
			}
		}

		private void frmReport_yc_Click(object sender, System.EventArgs e)
		{
			anlist();
		}
		//an list
		private void anlist()
		{
			listchuong.Hide();
			listdoituong.Hide();
			listhoatdong.Hide();
			listkhoanmuc1.Hide();
			listkhoanmuc2.Hide();
			listkhoanmuc3.Hide();
			listkhoanmuc4.Hide();
			listloaikhoan.Hide();
			listmuc.Hide();
			listnhombc.Hide();
			listtaikhoan.Hide();
		}

		private void butExcel_Click(object sender, System.EventArgs e)
		{
			Display(2);			

		}

		private void txtloaidt_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmloaidt!=null)
			{
				listloaidt.Focus();
				Filter_List(listloaidt,txtloaidt.Text.Trim(),"id","ten");
				listloaidt.BrowseToDmtk(txtloaidt,txttenloaidt,txtdoituong,txtloaidt.Location.X+8,114,txtloaidt.Width+0+txttenloaidt.Width,txttenloaidt.Height,100);
			}
		}

		private void txtloaidt_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmloaidt!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listloaidt.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listloaidt.Visible) 
					{
						listloaidt.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtloaidt_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtloaidt && dt_Dmloaidt!=null)
			{
				Filter_List(listloaidt,txtloaidt.Text.Trim(),"id","ten");
				listloaidt.BrowseToDmtk(txtloaidt,txttenloaidt,txtdoituong,txtloaidt.Location.X+8,114,txtloaidt.Width+0+txttenloaidt.Width,txttenloaidt.Height,100);
			}	
		}

		private void txtloaidt_Validated(object sender, System.EventArgs e)
		{
			txttenloaidt.Text="";
			if (txttenloaidt.Text!="")
			{
				r=a.getrowbyid(dt_Dmloaidt,"id='"+txtloaidt.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenloaidt.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}

		private void txtdoituong_Enter(object sender, System.EventArgs e)
		{			
			string s_IDloaidt="";
			try
			{
				if (txtloaidt.Text!="")
					s_IDloaidt=a.getrowbyid(dt_Dmloaidt,"id='"+txtloaidt.Text.Trim()+"'")["id"].ToString().Trim();				
				f_LoadDoituong(s_IDloaidt);
			}
			catch{}
		}		
	}
}
